Lab 6: Prize Roulette

Submitted by shaohan on Tue, 03/12/2013 - 21:57

I used a DC motor and Potentiometer to create a prize roulette. User can use the potentiometer to adjust the speed of the rotation, and a color ball (which represent a specific prize) will randomly drop during the roulette rotation.

 

Component Used:

1 - Arduino Uno Board

1 - Potentiometer

1 - 1k Resistor 

1 - Breadboard

1 - DC Motor

2 - AA Battery 

1 - 1N4004

1 - TIP 120

1 - Paper Roulette

Several paper balls

Several wires

 

Codes:

 

/*
 * 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 motorPin = 9; // select the pin for the Motor
//int val = 0;      // variable to store the value coming from the sensor
void setup() {
  Serial.begin(9600);
}
void loop() {
  
  int val = analogRead(potPin);    // read the value from the sensor, between 0 - 1024
  Serial.println(val);
 
  int voltage = val * 255.0 / 1024;
  analogWrite(motorPin, voltage); // analogWrite can be between 0-255
  Serial.println(voltage);
}
 
photo (3).JPG
0
Your rating: None
Drupal theme by Kiwi Themes.