Arduino DC Motor Speed Control Potentiometer
by Surya Krishnakumar in Circuits > Arduino
205071 Views, 84 Favorites, 0 Comments
Arduino DC Motor Speed Control Potentiometer
This instructable will guide you on how to controll the speed of a Dc motor with a potentiometer and an arduino...
Part List
1) Arduino
2) D.C. motor
3) NPN transistor TIP120
4) Rectifier Diode
5) 3* 220 ohms resitors
6) 10K Potentiometer
7) Breadboard
8) Jumper wires
9) Green led
10) Red led
11) Computer with Arduino IDE
Connect the Potentiometer
1) Connect the negative pin of the potentiometer to GNDPIN on the arduino.
2) Connect the signal pin of the potentiometer to AnalogPIN0 on the arduino.
3) Connect the positive pin of the potentiometer to 5VPIN on the arduino.
Connect the Leds
1) Connect a 220ohm or any ressitor below 1komhs to the anode of the red led and connect the end of the resistor to DIGITALPIN8 on the arduino.
2) Connect the cathode of the red led to GNDPIN.
3) Connect a 220ohms resistor to the anode of the green led and connect the end of the resistor to DIGITALPIN9 on the arduino.
4) Connect the cathode of the green led to GNDPIN.
Connect the Transistor,diode,resistor and the D.C.motor
1) Connect the BASE of the transistor to a 220ohms resitor and connect the end of the resistor to DIGITALPIN3 on the arduino.
2) Connect the COLLECTOR of the transistor to a negative of a diode and connect the end of the diode to GND.
3) Connect the EMITTER of the transistor to GND.
4) Connect a pin of the motor to 5v and another to negative of the Diode.
TIP 120 NPN Transistor Pinout
Breadboard Layout
Arduino Code
int analogInPin = A0;
int sensorValue = 0;
int outputValue = 0;
int transistorPin = 3;
void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(transistorPin, OUTPUT);
}
void loop()
{
sensorValue = analogRead(analogInPin)/4;
outputValue = map(sensorValue, 0, 1023, 0, 255);
analogWrite(transistorPin, sensorValue);
if (sensorValue >= 160)
{
//example
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
}
else
{ digitalWrite(9, HIGH);
digitalWrite(8, LOW);
}
delay(10); }