3 Push-Buttons and 3 motor speeds

 

Can you power the motor using the power through arduino? NO! Remember the Arduino can only source up to 40 mA of power at 5V. The motor uses up to 1000mA at 5v.....You must use a transistor and separate power supply to prevent damage to the Arduino.

You must know the pin configuration on the transistor. To find, look at the transistor and google the part number. For this lab I provided PN2222A transistors. Note: if you find a datasheet, make sure the image on the sheet looks like the part you have in your hand....

why do you need the transistor and separate power supply?

Build the transistor circuit and use the simple Blink program in Arduino to test the transistor circuit.

How can you use arduino to change the speed of the motor? analogWrite(pin, value) is a PWM or pulse-width modulation function, where the value can range from 0 (off) to 255 ( full on) and gives you the ability to provide partial power. Test this function out and see that you can change the speed of the motor using analogWrite.

NOTE: PWM only works on certain pins( 3, 5, 9, 10, 11) and is indicated on the Arduino board.

Refer to Ladyada Arduino tutorial Lesson 5 to set up a single push-button with pull-down resistor, and read its state ( HIGH 5V or LOW 0V ) Expand this to three push buttons.
http://www.ladyada.net/learn/arduino/lesson5.html

/*
* Simple switch test program
*/

void setup() // run once, when the sketch starts
{
Serial.begin(9600); // begin serial to serial monitor

}

void loop() // run over and over again
{

Serial.println(digitalRead(2)); // Read pin 2 and display the value
delay(100);
}

Use If () statements to create three different motor speeds using three push-buttons.