Spin the Wheel

by Neeraj N in Circuits > Arduino

13 Views, 1 Favorites, 0 Comments

Spin the Wheel

Complete #2.png

Hi! I am Neeraj N, and in this project, I will demonstrate to you how I created my interactive Arduino-based Spin the Wheel game. At the push of a button, the wheel rotates with the help of a DC motor of LEDs lit up and a piezo buzzer to provide sound effects so it is more entertaining. I also included a seven segment display to indicate a count down so that the player can be aware when to change the speed of the motors with a potentiometer. The project is based on a combination of hardware (wiring and assembling the circuit) and software (programming Arduino) to make an entertaining and educative electronic game. I hope you will learn and get inspired, either you are a beginner or you want to discover more about the Arduino world!

Supplies

Materials.png
  1. Breadboard x1 (where we will be combining and putting all of our components)
  2. Arduino Uno x1 (microcontroller that manages the whole system)
  3. Seven Segment Display x1 (visually displays the countdown)
  4. 2 LEDs (Red & Green) (used to show system status: ready, spinning, complete)
  5. Push Button x1 (used to initiate the whole system)
  6. DC Motor x1 (literally rotates the wheel)
  7. Piezo Buzzer x1 (adds sound effects)
  8. NPN Transistor x1 (switches the higher current needed by the DC motor safely through the Arduino)
  9. Potentiometer x1 (to adjust and control the speed of the motor)
  10. Capacitor x1 (to help smooth out voltage spikes)
  11. 6 Resistors:
  12. 2 × 330Ω (for LEDs)
  13. 2 × 330Ω (for Seven Segment Display)
  14. 1 × 330Ω (for Button Transistor)
  15. 1 × 1MΩ (used in motor control circuit)
  16. Wires (to connect all circuits)

Seven Segment Display Wiring

7 Seg Display Wiring Only.png
7-segemnt-pinout.png

A seven-segment display is an electronic indicator to visually represent numbers (0-9) and a few letters (A-F) with an LED patterned display. The digits or characters are each represented by illuminating some segments, marked A through G. Here we are going to work with a common anode seven segment display, so all the anodes of the internal LEDs are tied together, and the segments are enabled by grounding the appropriate cathode via the Arduino.

The seven-segment display needs to be wired like this to your Arduino:

  1. Connect segment A to the Arduino pin 13
  2. Connect segment B to the Arduino pin 12
  3. Connect segment C to Arduino pin 7
  4. Connect segment D to the Arduino pin 8
  5. Connect segment E to the Arduino pin 9
  6. Connect segment F to the Arduino pin 10
  7. Connect segment G to the Arduino pin 11
  8. Both common anode pins to the positive rail of the breadboard (usually 5V)

Important: Check your connections twice and have a look at the wiring diagram above as a visual aid. Make sure everything is connected correctly.

Piezometer Wiring

Piezo Wiring Only.png
piezo-buzzer-b-10n-piezo-electric-buzzers-rm0338-by-robomart-399.jpg

The piezo buzzer is a basic electronic device which makes sound with the application of voltage. In this project we are going to use it to provide audio feedback to our Spin the Wheel game. The piezo buzzer has two legs, a positive ( + ) and a negative (-), and it is really easy to connect.

Wiring it is like this:

  1. The positive (+) pin of the piezo buzzer leads to Arduino pin 6.
  2. The negative (-) pin of the piezo buzzer should be connected to the GND (negative rail) of the breadboard.

That’s it! When it is connected, you will be able to turn the buzzer on or off directly form your Arduino code using functions such as tone() and noTone() to produce various sounds and effects. Feel free again to look at the diagram above for the reference to make sure your connections are correct.

LEDs Wiring

LEDs Wiring.png
21-2-edited.jpg

In this project we are having two LEDs to give simple visual feedback, one red and one green. The red LED will be used to show when the system is waiting, whereas the green LED will be used to show when the motor is running.

Every LED has two legs:

  1. The positive (anode) side is the longer leg.
  2. The negative (cathode) leg is the short one.

They can be wired like this:

  1. Attach the positive leg (anode) of the red LED to Arduino pin A5.
  2. We will connect the anode (positive leg) of the green LED to Arduino pin A4.
  3. On the breadboard, connect the cathode (negative leg) of both LEDs to ground (negative rail) with a resistor.

To limit the current and to ensure the safety of the LEDs you can utilize a resistor with the range of 220-330. The resistors are necessary since they help to avoid excessive flow of current through the LEDs, which might destroy them. Again there are diagram's above if you need a visual representation.

Button Wiring

Button Wiring.png
push-button-switch-1000x1000.jpg

The spinning action of the wheel is initiated by the push button, which activates when pushed. The basic button is operated by completing or breaking the circuit on being pressed and the Arduino can sense when the user is ready to begin the game.

You can wire it like this:

  1. Put the button over the center gap of the breadboard (one side on one set of rails, and the other side on the other set of rails).
  2. On the button, connect one of the sides to Arduino pin 2.
  3. At the other end of the button:
  4. Connect one side to the positive rail (5V).
  5. On the same side, also connect a resistor (usually 10k ) to GND.

With this configuration, with the button not pressed, the resistor will pull the voltage low to GND, and thus pin 2 will be LOW. Once the button is pressed, 5V is sent to the pin and the Arduino reads HIGH. This is referred to as a pull-up resistor wiring, but manually rather than through Arduino internal pull-up. Look at the diagram above for a visual representation.

NPN & DC Motor Wiring

NPN Wiring.png
npn.jpg

In this project, the mechanical device that rotates the game wheel when energized is the DC motor. A DC motor is the one that changes electrical energy into rotary energy. The NPN transistor is a kind of electronic switch that enables the Arduino to switch the motor on or off with a little current without using the Arduino pins to power the motor directly. An electronic component soldered across the terminals of the motor is the ceramic capacitor which serves to filter electrical noises and voltage spikes generated by the moving parts of the motor to protect the circuit and provide better stability.

First: The Capacitor

I soldered a very small non-polarized ceramic capacitor directly across the two terminals of the DC motor before wiring the motor. This assists to:

  1. Eliminate electrical noise (some refer to it as motor noise), caused when the motor is rotating or stalled.
  2. Guard against the Arduino and other components against sudden voltage spikes induced by the brushes in the motor.
  3. Enhance stability of the circuit in general and when multiple components (LEDs, buzzer, seven-segment display, etc.) are operated in particular.

When dealing with small brushed DC motors this is a good practice to avoid glitches or unexpected resets.

Connection of Motor and NPN Transistor:

  1. The motor positive terminal connects to the positive rail (5V).
  2. The collector of the NPN transistor is linked to the negative terminal of the motor.
  3. The NPN transistor emitter is attached to GND.
  4. The base of the NPN transistor leads to Arduino pin 3.

If you would like, you can connect a current-limiting resistor around 220Ω to 1kΩ when connecting the base to pin 3. But you do not have to, as I just skipped it because not enough space available. Feel free to look at visual representations above.

Potentiometer Wiring

Complete circuit, and Potentiometer wiring.png
pot-pins.jpg

I am also applying a potentiometer in this project to vary the speed of the DC motor so as the wheel rotates at varying speeds. A potentiometer is a variable resistor that changes the voltage depending upon the amount you rotate the knob. It contains three pins, two outer terminals, and one wiper (middle pin), that moves when you turn the knob.

Connecting up the Potentiometer:

  1. Terminal 1 to 5V (positive rail).
  2. Connect Terminal 2 to GND (negative rail).
  3. Wiper (center pin) to one side of current-limiting resistor (not required, but may assist in noise filtering).
  4. Attach the other resistor leg to analog pin A1 of Arduino.

When you rotate the potentiometer, the voltage recorded at A1 changes, and this is what the Arduino reads to variate the speed of the motor in your program. Feel free again to look at the diagrams above to get a visual representation.

Complete Circuit

Complete #2.png

Since the whole circuit is completely wired and waiting, it is time to proceed to the coding aspect. Fortunately, I have already code this Spin the Wheel game. Just grab the code below, load it into your Arduino via the Arduino IDE and you are set to begin spinning your wheel! I have also attached a video of my circuit working below.