Introduction: Use Transistor As Motor Driver : Basic
Hello everyone, In this instructable we will be using transistor as a Motor Driver.
Actually, We can't say it as a Motor Driver as it can just toggle motor ON or OFF rather than controlling the motor speed or direction.
But, Using the transistor protects our Arduino from burning out. As ordinary DC motors runs on High Amps or consume more current than what an Arduino can supply.
Step 1: Gather the Parts
- An Arduino
- A breadboard
- A 220ohm resistor
- A 2N2222 transistor
- A DC motor
- A 9V battery
- Some jumper or hookup wires
Step 2: Wiring
Hookup all the components according to the circuit diagram shown above.
Step 3: The Code
As I mentioned above we can just toggle motor ON or OFF.
So, The following code turns the motor ON for 10 sec then turns it OFF for 5 sec and cycles through the process.
void setup() {
pinMode(13, OUTPUT);
}
void loop() {
digitalWrite(13, HIGH); // Turn the motor ON
delay(10000); // Wait for 10 secs
digitalWrite(13, LOW); // Turn the motor OFF
delay(5000); // Wait for 5 secs
}
Step 4: Done
Now Power the arduino and see your motor spinning.
Thanks for viewing.
Please write your questions or suggestions below.