2D Arduino Game: Alien Invasion
by AlexAndAmigos in Circuits > Arduino
1096 Views, 4 Favorites, 0 Comments
2D Arduino Game: Alien Invasion
![DSC00640.JPG](/proxy/?url=https://content.instructables.com/FNM/7FSK/IXGG0FWS/FNM7FSKIXGG0FWS.jpg&filename=DSC00640.JPG)
This is meant to be a fun little game about destroying aliens. When an alien appears you need to press the button to "zap" it with a blue LED. It may seem easy but it is actually slightly hard, due to the fact that you need to process the fact that an alien has appeared and you need to press the button and some people do not have very fast reflexes.
This uses an arduino UNO and skills learnt from the arduino class but mostly my brother.
Electronics
- 4x 220 - 1k resistors
- 2x Blue(or other color) LEDS
- 2x Red LEDS
- 1x small pushbutton(4 leads)
Various breadboard wires
1x Arduino UNO
- 1x 10k ohm resistor
The Hardware
![instru3.JPG](/proxy/?url=https://content.instructables.com/FEY/6UHW/IXGG0FT9/FEY6UHWIXGG0FT9.jpg&filename=instru3.JPG)
![DSC00630.JPG](/proxy/?url=https://content.instructables.com/FMQ/NQA9/IXGFTCWJ/FMQNQA9IXGFTCWJ.jpg&filename=DSC00630.JPG)
![instru2.JPG](/proxy/?url=https://content.instructables.com/FRX/MO38/IXGG0FRR/FRXMO38IXGG0FRR.jpg&filename=instru2.JPG)
![instru4.JPG](/proxy/?url=https://content.instructables.com/F9Y/HE3Z/IXGG0FTR/F9YHE3ZIXGG0FTR.jpg&filename=instru4.JPG)
![DSC00634.JPG](/proxy/?url=https://content.instructables.com/F7N/GNFQ/IXGG0FVD/F7NGNFQIXGG0FVD.jpg&filename=DSC00634.JPG)
![instru1.jpg](/proxy/?url=https://content.instructables.com/FRK/B9NT/IXGG0FRN/FRKB9NTIXGG0FRN.jpg&filename=instru1.jpg)
First attach a standard power system as in Fig.1. Then, put the button inbetween both the sides, and attach it to the power as in fig.2 and fig.3. Attach the button to pin 2. Set up the four 220k resistors to rows 1 and 20, 2 on each row as in fig.4. Then attach the blue LEDS, bent over to row 1, and the red ones to row 20. Attach the blue led on the left to pin 13 and the one on the right to pin 12, the left "alien" to pin 11, and the right one to pin 10. Make sure the leds are properly hooked up and the the negative end is attached to the resistor which is attached to the ground.
The Code
Download the file, and copy it over to your Arduino. The left "shooter" should flash and then after a random time one of the "aliens" will flash on. Press the button to "shoot" it. If the red LEDs flash, you have lost, if the blue leds flash you have won. It will take some "shots" for the blue LEDs to flash, And if you do not press the button quick enough you will lose and the game will automatically start over. Everything is randomly generated, so there is no telling where an alien will next pop up.