Arduio Dc Motor Speed Control Serial Monitor ..(no L293d)
by Surya Krishnakumar in Circuits > Arduino
19207 Views, 43 Favorites, 0 Comments
Arduio Dc Motor Speed Control Serial Monitor ..(no L293d)
This instructable will show you how to control the speed of a dc motor with PWM pins of arduino and serial monitor.
Part List
1) Arduino uno
2) small dc motor
3) 270ohms resistor or 220ohms or 330 ohms( anything bellow ik and above 220 will do).
4) Rectifier diode
5) Bc547 or any NPN transistor
6) breadboard
7) Jumper wires
Connecting the Transistor,Diode,Resistor and the D.C.motor
NOTE: place the transistor on the breadboard in such a way that the flat side faces you or the curved side faces away from you.
1) Connect the transistor's Collector to GND
2) Connect the transistor's Base to a 270ohm resitor and connect the resistor's end to DIGITALPIN3 on the arduino.
3) Connect the transistor's Emitter to the diode's negative(where there is no line).
4) Connect the end of the diode(negative where there is a line) to any of the D.C.motor's PIN
5) Connect the Diode's positive to 5v.
6) Connect the D.C.motor's another PIN to the transistor's Emitter PIN.
Breadboard Layout
Arduino Code
void setup()
{
pinMode(3, OUTPUT);// where the motor is connected to
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(3, speed);//sets the motors speed
}
}
}
THATS IT.
1) Upload your code.
2) Open the serial monitor.
3) Set it to no line ending.
4) Enter your HEX value from 0 to 255 and hit enter.