If we want to control a DC motor using Arduino, we have to go for some kinds of drivers such as ULN2803 or L293DNE. I had already published one blog on controlling a DC motor using L293D and Arduino. Controlling a DC motor using ULN2803 is pretty simple. But the problem is, we cannot change the direction of rotation of motor by this circuit. If you are not familiar with ULN2803, read this blog to get a brief idea.
Circuit diagram to control a DC motor using Arduino and ULN2803 is given below.
Circuit diagram to control a DC motor using Arduino and ULN2803 is given below.
Now upload the following program to arduino board.
int motor = 13;
void setup() {
pinMode(motor, OUTPUT);
}
void loop() {
digitalWrite(motor, HIGH);
delay(1000);
digitalWrite(motor, LOW);
delay(1000);
}
Output :
Motor will rotate for one second. Then motor will turn off for next one second and the process continues for ever.
0 comments: