Hey everyone
Let me just start off by saying I am very new to Arduino, circuits, and pretty much all of this, but I have to figure this out. That being said, I have a problem, and I'm not sure if I can even solve it with the components I have.
Basically I need to use some sort of an Arduino to power a DC motor, and that needs to be controlled via the program. I'm using an Arduino Nano, a breadboard, a motor controller (L298N), a DC motor, and a battery. I have all the necessary cables and wires.
I have a lot more experience programming, so I came up with this program (it compiles fine).
const int enB = 9;
const int in3 = 7;
const int in4 = 8;
void setup()
{
// set all the motor control pins to outputs
pinMode(enB, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}
void loop()
{
// turn on motor B
digitalWrite(in3, HIGH);
digitalWrite(in4, LOW);
// set speed to 200 out of possible range 0~255
analogWrite(enB, 200);
delay(5000);
// now change motor directions
digitalWrite(in3, LOW);
digitalWrite(in4, HIGH);
delay(5000);
// now turn off motors
digitalWrite(in3, LOW);
digitalWrite(in4, LOW);
}
Thanks




