Equipment:
- Arduino x 1
- Breadboard x 1
- Arduino Holder x 1
- CIRC-03 Breadboard Sheet x 1
- Transistor (P2N2222AG) x 1
- Wire x 8
- Toy Motor x 1
- Diode (1N4001) x 1
- 10k Ohm Resistor x 1
Reference:
- http://www.oomlout.com/a/products/ardx/circ-03
- http://ardx.org/src/circ/CIRC03-sheet-SPAR.pdf
- http://ardx.org/src/circ/CIRC03-code.txt
Program Details:
In this circuit, a few new items are introduced. First up, a diode; it looks like a resistor but longer and the center is in a cylinder shape. A diode allows the current to flow in one direction only. This is very useful when powering the toy motor. Second, a Transistor; a transistor has 3 leads on it with a black top. A transistor uses a small current to switch or amplify a larger current. This is used to power the toy motor because the current in the arduino is very small and won't be able to power the toy motor without the use of a transistor. Lastly, the toy motor itself. The toy motor has a black and red wire coming out of it and it looks like a motor. Its function is to spin when a current is passed through it.
For the programming part, no new methods are introduced even though we are using a motor instead of LEDs. However, we do learn that controlling a motor is very similar to controlling a LED. It is controlled by turning off and on and having a delay in between. The only difference is between variable names.
To create circuit-03 we followed the breadboard sheet and the programming step by step.
For the programming part, no new methods are introduced even though we are using a motor instead of LEDs. However, we do learn that controlling a motor is very similar to controlling a LED. It is controlled by turning off and on and having a delay in between. The only difference is between variable names.
To create circuit-03 we followed the breadboard sheet and the programming step by step.
Time to Complete: 10 mins to assemble
10 mins to program
Results: Our motor didn't run when we first ran the program. We discovered later that we have to change the Digital Ground to Power Ground. We also had to flip the wires of the motor because black is supposed to receive negative and red is to recieve positive. After that, our motor started working/vibrating although it didn't spin.
Photo:
Tips:
- Place black wire with negative flow and red wire with positive flow (of the motor)
- Connect the negative column to the ground in Power, not digital.
- Make sure you place the transistor correctly (connect the load to the collector, and the emitter to ground)
Further Work: I will try out the different methods given on my motor and then try to modify them to test out different things on the motor such as speed or acceleration.
Program Modifications:
No modifications were made, the code is the exact same as the one in the link below.
http://ardx.org/src/circ/CIRC03-code.txt
No modifications were made, the code is the exact same as the one in the link below.
http://ardx.org/src/circ/CIRC03-code.txt
Program:
int motorPin = 9; // pin number which the motor is connected to
void setup() // Runs once when program is intialized
{
pinMode(motorPin, OUTPUT); // sets the pin to be an output
}
void loop() // everything inside the loop is repeated
{
motorOnThenOff(); // calls the motorOnThenOff method
}
void motorOnThenOff() // This method will turn the motor on then off
{
int onTime = 2500; // Motor will stay on for 2500 milliseconds/2.5 seconds
int offTime = 1000; // Motor will turn off for 1000 milliseconds/1 second
digitalWrite(motorPin, HIGH); // turns the motor on
delay(onTime); // creates a delay for onTime milliseconds
digitalWrite(motorPin, LOW); // turns the motor off
delay(offTime); // creates a delay for offTime milliseconds
}
int motorPin = 9; // pin number which the motor is connected to
void setup() // Runs once when program is intialized
{
pinMode(motorPin, OUTPUT); // sets the pin to be an output
}
void loop() // everything inside the loop is repeated
{
motorOnThenOff(); // calls the motorOnThenOff method
}
void motorOnThenOff() // This method will turn the motor on then off
{
int onTime = 2500; // Motor will stay on for 2500 milliseconds/2.5 seconds
int offTime = 1000; // Motor will turn off for 1000 milliseconds/1 second
digitalWrite(motorPin, HIGH); // turns the motor on
delay(onTime); // creates a delay for onTime milliseconds
digitalWrite(motorPin, LOW); // turns the motor off
delay(offTime); // creates a delay for offTime milliseconds
}
No comments:
Post a Comment