hi im not sure whats wrong with my code it keeps saying “DCMDriverL293D.h no such file and directory”
Here is my code:
void setup() {
// put your setup code here, to run once:
}// Include Libraries
#include "Arduino.h"
#include "DCMDriverL293D.h":
// Pin Definitions
#define DCMOTORDRIVERA_PIN_ENABLE1 5
#define DCMOTORDRIVERA_PIN_IN1 2
#define DCMOTORDRIVERA_PIN_IN2 3
#define DCMOTORDRIVERA_PIN_ENABLE2 6
#define DCMOTORDRIVERA_PIN_IN3 4
#define DCMOTORDRIVERA_PIN_IN4 7
// Global variables and defines
// object initialization
DCMDriverL293D dcMotorDriverA(DCMOTORDRIVERA_PIN_ENABLE1,DCMOTORDRIVERA_PIN_IN1,DCMOTORDRIVERA_PIN_IN2,DCMOTORDRIVERA_PIN_ENABLE2,DCMOTORDRIVERA_PIN_IN3,DCMOTORDRIVERA_PIN_IN4);
// define vars for testing menu
const int timeout = 10000; //define timeout of 10 sec
char menuOption = 0;
long time0;
// Setup the essentials for your circuit to work. It runs first every time your circuit is powered with electricity.
void setup()
{
// Setup Serial which is useful for debugging
// Use the Serial Monitor to view printed messages
Serial.begin(9600);
while (!Serial) ; // wait for serial port to connect. Needed for native USB
Serial.println("start");
menuOption = menu();
}
// Main logic of your circuit. It defines the interaction between the components you selected. After setup, it runs over and over again, in an eternal loop.
void loop()
{
if(menuOption == '1') {
// L293D Motor Driver with Dual Hobby DC Motors - Test Code
//Start both motors. note that rotation direction is determined by the motors connection to the driver.
//You can change the speed by setting a value between 0-255, and set the direction by changing between 1 and 0.
dcMotorDriverA.setMotorA(200,1);
dcMotorDriverA.setMotorB(200,0);
delay(2000);
//Stop both motors
dcMotorDriverA.stopMotors();
delay(2000);
}
if (millis() - time0 > timeout)
{
menuOption = menu();
}
}
// Menu function for selecting the components to be tested
// Follow serial monitor for instrcutions
char menu()
{
Serial.println(F("\nWhich component would you like to test?"));
Serial.println(F("(1) L293D Motor Driver with Dual Hobby DC Motors"));
Serial.println(F("(menu) send anything else or press on board reset button\n"));
while (!Serial.available());
// Read data from serial monitor if received
while (Serial.available())
{
char c = Serial.read();
if (isAlphaNumeric(c))
{
if(c == '1')
Serial.println(F("Now Testing L293D Motor Driver with Dual Hobby DC Motors"));
else
{
Serial.println(F("illegal input!"));
return 0;
}
time0 = millis();
return c;
}
}
}
void loop() {
// put your main code here, to run repeatedly:
}int motorPin = 9;
void setup() {
pinMode(motorPin, OUTPUT);
Serial.begin(9600);
while (! Serial);
Serial.println("Speed 0 to 255");
}
void loop() {
if (Serial.available()) {
int speed = Serial.parseInt();
if (speed >= 0 && speed <= 255) {
analogWrite(motorPin, speed);
}
}
}
Edit by sivar2311: Used pre-formatted text to make the code easier to read.
Please use pre-formatted code when posting code or log files. Thanks in advance!