Carnival Lights Game
Introduction: Carnival Lights Game
Welcome to an Arduino beginner project. It's a simplification of my previous instructable; it's designed to be easier to reproduce.
This is a timing minigame where the active light moves back and forth across a row of lights in order. When the button is pressed the light stops. If the light stops on the center light the level and difficulty increases. If the button is pressed one away from the middle the level stays the same. 769
If the button is pressed and it lands on a light which isn't the middle three the level and speed are lowered.
To win the player must reach level ten when the display shows a smiley face.
Supplies
* Breadboard
* 11 LEDs preferably multiple colors and sizes (I used these and these)
* 12 resistors (220 ohms)
* Arduino Uno or Nano (Other boards should work as well)
* 1 push button
* 8x8 Keyestudio matrix
* Around 20 wires
* Arduino IDE
* Matrix Libraries
Step 1: Clarifications
I will use the terms in the above diagram to identify parts of the breadboard. This project can be made without the LED matrix since it's only used as a level display. If you choose not to use the LED matrix then the libraries are not necessary.
Step 2: LED Wiring
Wire the ground pin (GND) into one of the bus strips.
Order the LEDs so the center light will be clearly distinct from the others. I chose to order my LEDs red, white, orange, orange, medium green, center large green. I mirrored the pattern to the other side.
Place the positive end of each LED (long end) with three holes between them and insert the negative end into the ground bus strip.
From the positive end of each LED wire a resistor across the center divider. Then use jumper wires to connect digital ports 2-12 to the resistors in order.
Step 3: Push Button
Wire a 5V current into a bus rail opposite the LEDs and wire ground into the other rail.
Place the button straddles on the center divider.
Place a wire from the 5V bus rail to the push button.
From the other side of the pushbutton place a resistor into the ground bus rail and place a wire on the same row into D13.
Step 4: LED Matrix
Place the LED matrix into the breadboard.
Wire from the 5V power rail to the VCC pin.
Place a wire from the ground power rail to GND
Place a wire from A4 to SDA
Place a wire from A5 to SCL
Install the required matrix libraries from here
Step 5: Code
/*This a minigame where the active light moves back and forth across a row of lights in order.
* When it reaches the end it travels back in the opposite direction.
* When a button is pressed the light stops and if the light stops in the middle the level increases also increasing the speed.
* if the button is pressed one away from the middle the speed and level stays the same
* if the button is pressed and it lands on a light which isn't the middle or next to the middle the level and speed is lowered.
*
* Digital ports 2-12 are eached wired directly to the positive end of LEDs.
* The other end of the LED is in ground.
* The button has 5V in and a second wire in inputting to D13 and a resistor wired to ground
*
* The Matrix screen is wired:
* 5v to vcc
* GND to GND
* A4 to SDA
* A5 to SCL
*
* At a negative level a sad face is displayed and at levels > 10 a happy face is displayed.
*/
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack. 769