Asteroids Game Displayed on and LCD and Controlled by a Joystick

by 711245 in Circuits > Arduino

260 Views, 0 Favorites, 0 Comments

Asteroids Game Displayed on and LCD and Controlled by a Joystick

unnamed.jpg

Welcome to my tutorial! My name is Hamza Yousaf and I'm excited to share with you how to create a fun and engaging game using an Arduino and a 16x2 LCD screen. In this project, we'll be building an Asteroids-inspired game where you control a spacecraft on the left side of the screen and must navigate through incoming asteroids on the right. As you progress, the asteroids will increase in speed making the game more challenging. But don't worry, if you're hit, a buzzer will sound and you can simply press a push button to reset the game. We'll be using the Arduino sketch software and an Arduino board as the power source for this circuit. So, let's get started and go over the materials you'll need for this project.

Supplies

Wiring

j.PNG
circuit.PNG

Connect the 5V and GND pins from the Arduino to the breadboard, and connect the VCC and GND pins from the LCD to the breadboard as well. From the LCD connect the SDA pin to A4 and the SCL pin to A5 on the Arduino. On the breadboard, add a push button in the middle and connect a 330 ohm resistor to it, and also connect it to power and ground. Next, connect a wire from the resistor to pin 12 on the Arduino. Additionally, add 3 red LEDs, 1 yellow LED and 2 green LEDs to the breadboard, and connect a resistor to each one. Connect the yellow LED to pin 3, the 3 red LEDs to pins 4, 5 and 6, and the 2 green LEDs to pins 7 and 8 on the Arduino. Finally, connect power and ground from one side of the breadboard to the other to complete the circuit.


Connect the joystick X Y and SW pins as shown above, however, connect VCC and GND to the breadboard.

Coding

For the code, you will need to open the Arduino Sketch program on your computer. Once you have the program open, you will need to paste the provided code into the editor. Before you upload the code to your board, it is important to ensure that the correct port and board are selected in the Arduino IDE. To do this, go to the "Tools" menu and select the appropriate port and board from the options provided.

It's also a good idea to check if the correct libraries are installed, some codes may require additional libraries to be installed, if they are not already installed, you will have to download and install them before uploading the code.

Once you have confirmed that the correct port and board are selected, you can go ahead and upload the code to your board by clicking on the "Upload" button. This will upload the code to your board and make it ready for use.

Remember that if you run into any issues uploading the code or if the code gives an error, you should check the code and see if there are any errors or typos in the code and make sure that the libraries are installed correctly.

Downloads

Conlcusion

Once you have completed all of the steps outlined in the instructions, your game should be fully functional and running. You will be able to control the game by moving the joystick up and down. However, if you encounter any issues with the game constantly resetting, it could be an indication that the push button is not wired in properly. In this case, double-check the connections for the push button and ensure that they are properly connected to the power and ground on the breadboard, as well as to pin 12 on the Arduino. Additionally, you should also review the connections for all the other components to make sure that they are wired correctly, and that there are no loose connections. With all the connections secure, you should be able to enjoy your game without any interruptions. You can tape the joystick and LCD to a prop such as a box to make an old classic arcade style aesthetic.