Airhockey LED
This is an airhockey/pong game we created at school. It's a simple project for beginners. We have 16 leds in the order 3 red leds - 10 green leds - 3 red leds. Then we have 2 buttons. The game works like this:
You have 2 competitors. 1 button each. A "lightball" will travel from 1 side to the other. The goal is to press the button when the lightball is within your "goal" (the 3 red leds). If you manage to press the button when the lightball is within your goal the lightball will change direction and start to travel the other way, towards your competitiors goal. There are 2 ways of scoring, when your opponent misses his chance and the ball travels through all his 3 leds, and if your opponent press his button when it's not his turn (when the lightball is on the green leds or in your goal). When someone scores, the leds will act as a scoreboard for a few seconds. For instance, player 1 wasn't quick enough so the lightball doesn't change direction. Then the first red led on player 2's side will light up, indicating he has 1 point. If it happens again, 2 red leds will light up at player 2's side. This goes on 'til someone gets 8. Every time someone scores a speaker will play a short melody as a celebration.
The buttons are working as long as they are pressed, so be careful if you press at led nr 3. When the lightball changes direction it starts with a green, if your finger is still on the button your opponent will score. Aim at the second red led if you want to play safe.
Materials
List: 1 Arduino Uno, 1-2 Breadboard (depending on size), 16 Leds, 2 buttons, 16 220 ohm, 1 speaker, 2 shift registers(74HC595), a lot of wires.
Assemble
Nothing hard really, just follow the circuit diagram. Use 2 breadboards like we did if you don't have enough space on 1.
Code
The code works up to score 8, then you have to press "reset" on the arduino to start it all over again. The melody playing is actually "seven nation army". However, it plays fast, if you want it to play the "correct" melody you just have to change the delays at the tone-part and eventually you will find the right melody.