Hello everyone! In this tutorial I will show you how to use and code joystick module with an Arduino Uno Rev3 (board) and PictoBlox (software).
Understanding the gameThe goal of this game is to shoot with an aim as much as possible monsters. You move your aim with joystick module.
Things neededFor this project, you will need:
1x Arduino Uno
1x Joystick module
1x Breadboard
A few wires (generic)
ConnectionsNow lets connect joystick to Arduino.
(Component - Arduino)
Joystick
+5V - Pin 5V
GND - Pin GND
VRx - Analog pin A0
VRy - Analog pin A1
SW - Digital pin 3
CircuitHere's a circuit for connections:
Now, after connecting all things, let's pick sprites and backdrops. You don't need to pick same things as me if you don't want it. So, I will pick these sprites:
1x Monster
1x Aim
And the backdrop "Space".
This image is showing you how to pick a new sprite.
And this image is showing you how to pick a new backdrop.
Coding the monsterI'm picked a Monster sprite, and now I will show you how to code it:
Now it's time to program Aim sprite.
The logic is simple: As soon as the aim sprite touches the monster, the score will increase by one.
Write the following code:
Now we need to upload this code to Arduino:
Click the button "Upload Firmware".
__________________________________________
And now that's it! Now test the game. You also can change sprites and backdrops.
Comments
Please log in or sign up to comment.