Lab 6: DC Motors..Try your luck today!
Description:
We explored using the DC Motors in this lab. This assignment required us to use transistors and diodes to control a DC Motor using an input sensor(Pot). I decided to make a roulette for the hwk assignment since the motor can be used to replicate that motion.
Components Used:
- Arduino Micro-controller
- 1 Resistor (1K Ohms)
- Wires/Bread Board
- Potentiometer
- Transistor
- Diode
- DC Motor
- Materials to make the roulette
Roulette (HW):
For HW, I created a roulette using recycled material. The motor spins the wheel and the pot can be used to control its speed. Once the roulette is spinning at full speed the user can place his bet by throwing a bead on the wheel and see where it lands. The motor can then be stopped by pressing the FSR sensor.
There is also an illusion in the center of the roulette to give it a nice pattern when it is spinning fast.
Click here to watch me try my luck on the roulette.
Arduino Code:
/*
* one pot fades one motor
* modified version of AnalogInput
* by DojoDave <http://www.0j0.org>
* http://www.arduino.cc/en/Tutorial/AnalogInput
* Modified again by dave
*/
int potPin = 0; // select the input pin for the potentiometer
int fsrPin = 1; // select the input pin for fsr.
int motorPin = 9; // select the pin for the Motor
int valPot = 0; // variable to store the value coming from the sensor
int valFsr = 0;
void setup() {
Serial.begin(9600);
}
void loop() {
valPin = analogRead(potPin); // read the value from the sensor, between 0 - 1024
valFsr = analogRead(potFsr);
Serial.println(val);
analogWrite(motorPin, val/4); // analogWrite can be between 0-255
if(valFsr > 900)
analogWrite(motorPin, 0);
}
(2 votes)