Spin the Wheel Arduino

by 779199 in Circuits > Arduino

34 Views, 0 Favorites, 0 Comments

Spin the Wheel Arduino

24-inch-NEW-spin-to-win-dry-erase-prize-wheel-12_copy__87856.jpg

Hi. My name Is Sahil. I will be showing you my final project. This game is about spinning the wheel. This game aims to spin the wheel with an IR remote. When you press on the remote again the wheel stops and you get to watch the countdown on the seven segments and will have a chance to win a prize!

Supplies

  1. Arduino Uno x1
  2. Seven Segment display x1
  3. Servo Motot
  4. Push button x1
  5. LED's (Green and Red)
  6. 5 Resistors ( Three 330 and one 1k)
  7. IR Receiver And Remote X1
  8. Wires
  9. Breadboard

Wiring

IMG_2777.jpg

First, How I created this project was I looked at this photo and would make the same connections into my breadboard. I first connected the Seven Segment Display, IR sensors and the push button. Then I added the Resistors to the proper spot and then I would connect everything using jumper wires. Afterward, I would use my Arduino and connect my seven segments to my digital pins alongside the pushbutton, connecting them to my digital pin. Lastly, I would connect my LED and Servo motor into the analog pins.

CODE

In this step, I would put my code into my project. Here is my code Below.

#include <Servo.h>

#include <IRremote.h>


int a = 13;

int b = 12;

int c = 7;

int d = 8;

int e = 9;

int g = 11;

int f = 10;


int greenLed = A4;

int redLed = A5;

int completeBtn = 2;


Servo myServo;


int RECV_PIN = 5;

IRrecv irrecv(RECV_PIN);

decode_results results;

#define code1 490// code recived from negative button


void setup()

{

myServo.attach(3);

pinMode(a,OUTPUT);

pinMode(b,OUTPUT);

pinMode(c,OUTPUT);

pinMode(d,OUTPUT);

pinMode(e,OUTPUT);

pinMode(f,OUTPUT);

pinMode(g,OUTPUT);

pinMode(greenLed,OUTPUT);

pinMode(redLed,OUTPUT);

pinMode (completeBtn, INPUT);

Serial.begin(9600);

irrecv.enableIRIn();

}

void nine()

{

digitalWrite(a, LOW);

digitalWrite(b, LOW);

digitalWrite(c, LOW);

digitalWrite(g, LOW);

digitalWrite(f, LOW);

digitalWrite(e, HIGH);

digitalWrite(d, HIGH);

}

void eight()

{

digitalWrite(a, LOW);

digitalWrite(b, LOW);

digitalWrite(c, LOW);

digitalWrite(g, LOW);

digitalWrite(f, LOW);

digitalWrite(e, LOW);

digitalWrite(d, LOW);

}

void seven()

{

digitalWrite(a, LOW);

digitalWrite(b, LOW);

digitalWrite(c, LOW);

digitalWrite(g, HIGH);

digitalWrite(f, HIGH);

digitalWrite(e, HIGH);

digitalWrite(d, HIGH);

}

void six()

{

digitalWrite(a, LOW);

digitalWrite(b, HIGH);

digitalWrite(c, LOW);

digitalWrite(g, LOW);

digitalWrite(f, LOW);

digitalWrite(e, LOW);

digitalWrite(d, LOW);

}

void five()

{

digitalWrite(a, LOW);

digitalWrite(b, HIGH);

digitalWrite(c, LOW);

digitalWrite(g, LOW);

digitalWrite(f, LOW);

digitalWrite(e, HIGH);

digitalWrite(d, LOW);

}

void four()

{

digitalWrite(a, HIGH);

digitalWrite(b, LOW);

digitalWrite(c, LOW);

digitalWrite(g, LOW);

digitalWrite(f, LOW);

digitalWrite(e, HIGH);

digitalWrite(d, HIGH);

}

void three()

{

digitalWrite(a, LOW);

digitalWrite(b, LOW);

digitalWrite(c, LOW);

digitalWrite(g, LOW);

digitalWrite(f, HIGH);

digitalWrite(e, HIGH);

digitalWrite(d, LOW);

}

void two()

{

digitalWrite(a, LOW);

digitalWrite(b, LOW);

digitalWrite(c, HIGH);

digitalWrite(g, LOW);

digitalWrite(f, HIGH);

digitalWrite(e, LOW);

digitalWrite(d, LOW);

}

void one()

{

digitalWrite(a, HIGH);

digitalWrite(b, LOW);

digitalWrite(c, LOW);

digitalWrite(g, HIGH);

digitalWrite(f, HIGH);

digitalWrite(e, HIGH);

digitalWrite(d, HIGH);

}

void zero()

{

digitalWrite(a, LOW);

digitalWrite(b, LOW);

digitalWrite(c, LOW);

digitalWrite(g, HIGH);

digitalWrite(f, LOW);

digitalWrite(e, LOW);

digitalWrite(d, LOW);

}

void countdown()

{

nine();

delay(1000);

eight();

delay(1000);

seven();

delay(1000);

six();

delay(1000);

five();

delay(1000);

four();

delay(1000);

three();

delay(1000);

two();

delay(1000);

one();

delay(1000);

zero();

delay(1000);

}


void servoMotor ()

{

// stop rotation

delay(2000);

myServo.write(90);

}


void loop ()

{

myServo.write(0);

//delay(3000);

//myServo.write(90);

//delay(5000);

//countdown();

//delay (5000);

if (digitalRead(completeBtn) == HIGH){

digitalWrite(greenLed, HIGH);

digitalWrite(redLed, LOW);

}

else {

digitalWrite(greenLed, LOW);

digitalWrite(redLed, HIGH);

}

if (irrecv.decode(&results)){

Serial.println(results.value,HEX);

if (results.value == 0x490) //reciver recives 490 hex

{

myServo.write (90);

countdown();

}

else myServo.write (180);

irrecv.resume(); // Receive the next value

}

}


DEMO VIDEO

Here is a demo video of my project in action!


Thank you for reading this. Have a great day and try this out!

Downloads