Get the toy motor to spin.
Equipment:
•1 x Arduino Uno
•1 x Breadboard
•6 x Wire
•1 x Toy Motor
•1 x Transistor
•1 x Diode
•1 x 2.2k Ohm Resistor
Reference:
http://www.oomlout.com/a/products/ardx/circ-03
Program Details:
Same methods as CIRC-01. Motors are initialized the same LEDs are.
Time to Complete:
10 minutes
Results:
Forgot to upload the program, after uploading, the motor still wasn't spinning. Turns out the positive and negative on the motor was hooked up incorrectly. After fixing the connection, the motor began to spin.
Photos of Project:
Tips:
Watch out for the pesky positive and negative connections.
Further Work:
We can change the speed or acceleration of the motor.
Program Modifications:
The program is exactly the one from http://www.oomlout.com/a/products/ardx/circ-03
Program:
int motorPin = 9; // the pin the motor is connected to
void setup()
{
pinMode(motorPin, OUTPUT); //initalizes pin 9 as an output
}
void setup()
{
pinMode(motorPin, OUTPUT); //initalizes pin 9 as an output
}
void loop() // Continuously runs
{
motorOnThenOff(); //Calls the function motorOnThenOff
}
{
motorOnThenOff(); //Calls the function motorOnThenOff
}
void motorOnThenOff() //creates a void-type function, motorOnThenOff
{
int onTime = 2500; //time(in milliseconds) the motor is set to turn on for
int offTime = 1000; // time(in milliseconds) the motor is set to turn off for
digitalWrite(motorPin, HIGH); // changes the state of the pin9 to On
delay(onTime); // delay equal to the value of onTime
digitalWrite(motorPin, LOW); // changes the state of the pin9 to Off
delay(offTime); // delay equal to the value of offTime
}
int onTime = 2500; //time(in milliseconds) the motor is set to turn on for
int offTime = 1000; // time(in milliseconds) the motor is set to turn off for
digitalWrite(motorPin, HIGH); // changes the state of the pin9 to On
delay(onTime); // delay equal to the value of onTime
digitalWrite(motorPin, LOW); // changes the state of the pin9 to Off
delay(offTime); // delay equal to the value of offTime
}
}
No comments:
Post a Comment