Introduction: Flappy Bird Using Arduino and Processing
Hello everyone!!!
Welcome to a new Arduino based project. We all have once in our life time played the flappy bird game. How if we play it on our PC and control it using our Arduino?? Follow all the steps given below and by the end of this tutorial you will control the game using your microcontroller.
Step 1: Get the Supplies
So for this project we will be using an Arduino Uno Board and an SR-04 Ultrasonic sensor. I recommend you to buy these components from UTSource.net as they provide low cost electronics components and modules with no compromise in quality. Do check them out!!!
1 X Arduino Uno
A breadboard(optional) and few header wires
Step 2: Working in Brief
The reason we used the ultrasonic sensor here is to get the distance data between our hand and the
sensor and use those values to adjust the height of the moving bird. The game is created in Processing and the Arduino communicates with it using the serial port. I have linked few images of the game above so take a look at them in order to get some idea about this project.
Step 3: Let's Do the Connections
First connect the SR-04
sensor to the Arduino board. As there is just one sensor to interface I won't add a circuit diagram for this project. The connections are as follows -
SR-04 >> Arduino Uno
Vcc >> 5V
Gnd >> Gnd
Trigger Pin >> Digital pin 11
Echo Pin >> Digital pin 10
That's it the connections are done.
Step 4: Upload the Arduino Code
Now time to upload the code to your Arduino board.
Download the code from below.
Before uploading the code make sure to select the proper com port and baud rate as we will be using it for sending data to the game.
***************************************************
void setup()
{
pinMode(trigPin,OUTPUT);
pinMode(echoPin,INPUT);
Serial.begin(9600); // Set the baud rate here
}
*******************************************************
Attachments
Step 5: Open the Processing Program
Once the Arduino code is uploaded, download and open the
processing code. Again set the same baud rate and mention the correct com port as you did earlier.
*******************************************************
void setup(){
size(400,600);
p1.x = width + 50;
p2.x = width + 220;
p3.x = width + 370;
myPort = new Serial(this, "COM3", 9600); //Change the com port and baud rate here
myPort.bufferUntil(10);
}
********************************************************
Now let's give this game a try. Just click on the run button in the processing Ide and you are good to go.
The bird moves according to the distance between your hand and the sensor.
Hope you liked this small instructable. If yes then please show some support by hitting the favourite button also share it with your friends. If you need any assistance feel free to comment below. That's it for today guys. See you'll soon with another awesome project.