Introduction: Arduio Dc Motor Speed Control Serial Monitor ..(no L293d)

Picture of 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.

Step 1: Part List

Picture of 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

Step 2: 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.

Step 3: Breadboard Layout

Picture of Breadboard Layout

Step 4: Arduino Code

Picture of 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

}

}

}

Step 5: 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.

Comments

Surya Krishnakumar (author)2017-06-04

Hellow Friends :D Could you please spare some time and checkout my new instructable ? https://www.instructables.com/id/Simple-LM386-Powe...

Thanks a lot for all your support and appreciations. :D

waelpcb (author)2016-02-18

please, when i was writting that command

{int speed = Serial.parselnt();

it showed me that error while verifing

'class HardwareSerial' has no member named 'parselnt'

please advice ASAP as i'm working on it with final steps

Starbuck7410 (author)waelpcb2016-11-22

The command is int speed = Serial.parseint() with a capital i

koz12 (author)2015-05-07

Line side of a diode or cathode side is negative. Anode side is positive. Is the diode acting as a fly back?

Surya Krishnakumar (author)koz122015-05-08

Sorry for the wrong and dangerous information... It's the opposite as shown in the instructable... i will edi thee instructable as soon as possible.. hope u liked it.

koz12 (author)Surya Krishnakumar2015-05-09

No worries. It's an interesting little circuit. A schematic would be a nice addition. So this is basically a pwm motor speed test whereas the input is a 0-255 and the output is observed at the motor. If you wanted to extend on the circuit, you could use a potentiometer on a input pin instead of reading from the serial monitor?

About This Instructable

9,503views

43favorites

License:

More by Surya Krishnakumar:Arduino HCSR04 leds distance warnerArduino DC Motor Speed Control PotentiometerArduio Dc motor speed control serial monitor ..(no l293d)
Add instructable to: