Sie sind auf Seite 1von 29

FLAPPY BIRD GAME USING ARDUINO

Submitted in partial fulfillment of the


Requirement for the award of the
Degree of

BACHELOR OF TECHNOLOGY
IN

Electronics & Communication Engineering

By

M.V.RAMI REDDY - 180040161

R.V.N SRIKANTH - 180040180

Under the Guidance of

Mr. MADHAV PRASAD KHANAL


Assistant Professor

EMBEDDED CONTROLLERS

DEPARTMENT OF ELECTRONICS AND COMMUNICATION

ENGINEERING

KLEF

NOVEMBER 2019
DECLARATION

We students M.V,RAMI REDDY - 180040161,R.V.N .SRIKANTH - 180040180 of B. Tech


under Department of Electronics and Communication, K L University, Vaddeswaram ,
hereby declare that all the information furnished in this report is based on our own
intensive research and is genuine.

This report does not, to the best of my knowledge, contain part of our work which has
been submitted for the award of our degree either of this university or any other
university without proper citation.

M.V.RAMI REDDY - 180040161

R.V.N .SRIKANTH - 180040180


KLEF

DEPARTMENT OF ECE

EMBEDDED CONTROLLERS(19 EC 2206)

CERTIFICATE
This is to certify that the project based laboratory report entitled “ FLAPPY BIRD GAME
USING ARDUINO” submitted by M.V.RAMIREDDY-180040161,R.V.N.SRIKANTH-
180040180 to the Department of Electronics and Communication Engineering, KL
University in partial fulfillment of the requirements for the completion of a project based
Laboratory in “EMBEDDED CONTROLLERS” course in II year B Tech I Semester, is a
bonafide record of the work carried out by him/her under my supervision during the
academic year 2019 – 2020.

Signature of Course Instructor Signature of the Course Coordinator

Signature of HOD
ACKNOWLEDGEMENT

It is great pleasure for me to express my gratitude to our honorable President


Sri. Koneru Satyanarayana, for giving the opportunity and platform with facilities in
accomplishing the project based laboratory report.

I express the sincere gratitude to our principal Dr.K.Subba Rao for his
administration towards our academic growth.

I express sincere gratitude to our Coordinator Mr.Madhav Khanal for his leadership
and constant motivation provided in successful completion of our academic semester.

I record it as my privilege to deeply thank our pioneer Dr.CH.K.SRI KAVYA, HOD


for providing us the efficient faculty and facilities to make our ideas into reality.

I express my sincere thanks to our project supervisor Mr.Madhav Khanal for


his novel association of ideas, encouragement, appreciation and intellectual zeal
which motivated us to venture this project successfully.

Finally, it is pleased to acknowledge the indebtedness to all those who


devoted themselves directly or indirectly to make this project report success.
ABSTRACT

Flappy Bird was a side scrolling game developed by Dong Nguyen.Even though the game is
based on 2D Graphics, it became quite popular on both Android and iOS platforms. The aim
of the game is simple, try to fly the bird, which is called “Faby”, between the green pipes
without hitting them. Due to its addictive nature, the developer of the game discontinued the
game from both the channels (Google Play Store and App Store) but a revised version for
Amazon Fire TV is launched on Amazon App Store.The popularity of the lead to many
replica games and cloned versions were released. In this project, we will take the
concept of the game and implement a Flappy Bird Game using Arduino. Since Arduino is a
simple microcontroller platform, we don’t want to invest heavily into the project and
implement the Flappy Bird Game using Arduino, 16×2 LCD Display and a Push Button.

Video games have been disappointing parents for many decades. Some people have
argued that video games leads to violence. However, new research shows that video games
can be used for exercise, stress relievers, positive interactive learning, hand eye
coordination, and different types of patient treatment for people all around the world. When
playing video games, the coordination and concentration can physically, socially, and
mentally benefit the user. Research today shows that certain video games can reduce fat
and therefore promote weight loss. Other sources state that doctors have instructed parents
to let their children play video games to help control focus.
In our olden days we used to play games in type phones like pacman,snake game etc. In our
project we are generating that type of game using arduino.
We are using the following components in this project:

a. Arduino
b. Lcd screen[16*2]
c. Bread board
d. Resistor[220 ohm]
e. Push button switch
f. Jumper wires
g. Usb a to b cable

.
TABLE OF CONTENTS

CHAPTER-1.INTRODUCTION………………………………………………………………….....1

CHAPTER-2.COMPONENTS……………………………………………………………………

2.1 Arduino…………………………………………………………………................................

2.2 LCD 16x2 Display………………………………………………………………………....

2.3 Potentiometer……………………………………………………………………………...

2.4 Bread Board………………………………………………………………….....................

2.5 Jumper wires……………………………………………………………………….......

2.6 Push Button……………………………………………………………………………..

2.7 Resistor………………………………………………………………….............................

CHAPTER-3.CONCEPT OF FLAPPY BIRD GAME…………………………………………

3.1 Concept…………………………………………………………………...............................

3.2 Circuit Diagam……………………………………………………………………….......

3.3 Circuit Design……………………………………………………………………………..

3.4 Circuitary………………………………………………………………….............................

CHAPTER-4.CODE AND WORKING ……………………………………………………….

4.1 Code…………………………………………………………………..................................

4.2 Working of Flappy bird game………………………………………………..............

4.3 Outputs……………………………………………………………………………………
4.4 Game play………………………………………………………………………................

4.5 History……………………………………………………………………………………….

CHAPTER-5 ………………………………………………………………………………………

5.1 Conclusion…………………………………………………………………...........................

5.2 Reference………………………………………………................................................
\

LIST OF FIGURES

S.NO FIGURE NAME PAGE.NO

1. Introduction

2. Components

3. Arduino

4. LCD 16x2 Display

5. Potentiometer

Concept of flappy bird game


6. &

7. Circuit diagram
Circuit design
8.
10. Circuitary

11. Code

12. Working

13. Outputs

14. Game play

15. History

16. Conclusion
CHAPTER 1: INTRODUCTION

Flappy Bird was a side scrolling game developed by Dong Nguyen. Even though the game
is based on 2D Graphics, it became quite popular on both Android and iOS platforms. The
aim of the game is simple, try to fly the bird, which is called “Faby”, between the green pipes
without hitting them.

Due to its addictive nature, the developer of the game discontinued the game from both the
channels (Google Play Store and App Store) but a revised version for Amazon Fire TV is
launched on Amazon App Store.

The popularity of the lead to many replica games and cloned versions were released. In this
project, I will take the concept of the game and implement a DIY type Flappy Bird Game
using Arduino.

Since Arduino is a simple microcontroller platform, I don’t want to invest heavily into the
project and implement the Flappy Bird Game using Arduino, 16×2 LCD Display and a Push
Button.

If you are interested and willing to go further, you can implement a colorful version of the
Flappy Bird Game using Arduino along with a 1.8” Color Display and a few special graphics
related libraries for Arduino.
CHAPTER 2: COMPONENTS USED

a. Arduino
b. Lcd screen[16*2]
c. Bread board
d. Resistor[220 ohm]
e. Push button switch
f. Jumper wires
g. Usb a to b cable
2.1: ARDUINO

Arduino is an open-source electronics platform based on easy-to-use hardware and


software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or
a Twitter message - and turn it into an output - activating a motor, turning on an LED,
publishing something online. You can tell your board what to do by sending a set of
instructions to the microcontroller on the board. To do so you use the Arduino programming
language (based on Wiring), and the Arduino Software (IDE), based on Processing.

Over the years Arduino has been the brain of thousands of projects, from everyday objects
to complex scientific instruments. A worldwide community of makers - students, hobbyists,
artists, programmers, and professionals - has gathered around this open-source platform,
their contributions have added up to an incredible amount of accessible knowledge that can
be of great help to novices and experts alike.

Arduino was born at the Ivrea Interaction Design Institute as an easy tool for fast
prototyping, aimed at students without a background in electronics and programming. As
soon as it reached a wider community, the Arduino board started changing to adapt to new
needs and challenges, differentiating its offer from simple 8-bit boards to products
for IoT applications, wearable, 3D printing, and embedded environments. All Arduino boards
are completely open-source, empowering users to build them independently and eventually
adapt them to their particular needs. The software, too, is open-source, and it is growing
through the contributions of users worldwide.

.
2.2: LCD DISPLAY 16X2

We come across LCD displays everywhere around us. Computers, calculators, television
sets, mobile phones, digital watches use some kind of display to display the time. An LCD is
an electronic display module which uses liquid crystal to produce a visible image. The 16×2
LCD display is a very basic module commonly used in DIYs and circuits. The16×2 translates
o a display 16 characters per line in 2 such lines. In this LCD each character is displayed in
a 5×7 pixel matrix

RS (Register select):

A 16X2 LCD has two registers, namely, command and data. The register select is used to
switch from one register to other. RS=0 for command register, whereas RS=1 for data
register.

Command Register: The command register stores the command instructions given to
the LCD. A command is an instruction given to LCD to do a predefined task like initializing it,
clearing its screen, setting the cursor position, controlling display etc. Processing for
commands happens in the command register.

Data Register: The data register stores the data to be displayed on the LCD. The data is
the ASCII value of the character to be displayed on the LCD. When we send data to LCD it
goes to the data register and is processed there. When RS=1, data register is selected.
2.3: POTENTIOMETER

A potentiometer is a three-terminal resistor with a sliding or rotating contact that forms an


adjustable voltage divider. If only two terminals are used, one end and the wiper, it acts as
a variable resistor or rheostat.
The measuring instrument called a potentiometer is essentially a voltage divider used for
measuring electric potential (voltage); the component is an implementation of the same
principle, hence its name.
Potentiometers are commonly used to control electrical devices such as volume controls on
audio equipment. Potentiometers operated by a mechanism can be used as
position transducers, for example, in a joystick. Potentiometers are rarely used to directly
control significant power (more than a watt), since the power dissipated in the potentiometer
would be comparable to the power in the controlled load.
Potentiometers consist of a resistive element, a sliding contact (wiper) that moves along the
element, making good electrical contact with one part of it, electrical terminals at each end of
the element, a mechanism that moves the wiper from one end to the other, and a housing
containing the element and wiper.
See drawing. Many inexpensive potentiometers are constructed with a resistive
element formed into an arc of a circle usually a little less than a full turn and a wiper sliding
on this element when rotated, making electrical contact. The resistive element can be flat or
angled. Each end of the resistive element is connected to a terminal on the case. The wiper
is connected to a third terminal , usually between the other two. On panel potentiometers,
the wiper is usually the center terminal of three. For single-turn potentiometers, this wiper
typically travels just under one revolution around the contact.
2.4: BREAD BOARD

A breadboard is a solderless device for temporary prototype with electronics and test circuit
designs. Most electronic components in electronic circuits can be interconnected by inserting
their leads or terminals into the holes and then making connections through wires where
appropriate. The breadboard has strips of metal underneath the board and connect the
holes on the top of the board. The metal strips are laid out as shown below. Note that the top
and bottom rows of holes are connected horizontally and split in the middle while the
remaining holes are connected vertically.

2.5: JUMPER WIRES

Jumper wires are simply wires that have connector pins at each end, allowing them to be
used to connect two points to each other without soldering. Jumper wires are typically used
with breadboards and other prototyping tools in order to make it easy to change a circuit as
needed. Fairly simple. In fact, it doesn’t get much more basic than jumper wires.
2.6: PUSH BUTTON

A push button is a simple type of switch that controls an action in a machine or some type of
process. Most of the time, the buttons are plastic or metal. The shape of the push button
may conform to fingers or hands for easy use, or they may simply be flat. It all depends on
the individual design. The push button can be normally open or normally closed.

2.7:RESISTOR (220OHM)

A resistor is a passive two-terminal electrical component that implements


electrical resistance as a circuit element. Resistors act to reduce current flow, and, at the
same time, act to lower voltage levels within circuits.
CHAPTER 3: CONCEPT OF FLAPPY BIRD GAME

3.1:CONCEPT

The main concept of the Flappy Bird Game using Arduino is very simple. I have replicated
the bird with the character “0” and the obstacles with s string of the character “#”.

Actually, I have made two such strings with different combinations of the character “#”, one
for the top row and the other for bottom row.

The aim of the game is to successfully pass the “bird” through these “obstacles” simply by
pushing the button.

Before proceeding further, the concept of “Interrupts” in Arduino is very essential to


implement this project. So, I suggest you to go through this simple Arduino interrupts, where
you can easily understand how to use Interrupts on Arduino.
3.2: CIRCUIT DIAGRAM

The circuit diagram of the project DIY Flappy Bird Game using Arduino is shown in the
following image.
3.3: CIRCUIT DESIGN

From the circuit diagram and the list of the components required, you can get an idea of how
simple the implementation of the project is. All you need is to interface a 16×2 LCD display
with Arduino UNO and also add an Interrupt Button.

Coming to the 16×2 LCD Display, connect its RS and E pins to Digital I/O Pins 8 and 7 of
Arduino UNO. The Data Pins D4 – D7 are connected to 6, 5, 4 and 3 Pins of Arduino.

A 10KΩ POT is connected to adjust the contrast of the 16×2 LCD Display. All other
connections are clearly mentioned in the circuit diagram.

A Push Button is connected between Pin 2 and GND


3.4: CIRCUITARY

This game is basically like the T-Rex run on Google but in this rendition there is a man.
Basic Connections:
 connect 5v pin of Arduino to positive rail of breadboard
 connect GND of Arduino to negative rail of breadboard
LCD Connections:
 VSS to negative rail
 VCC to positive rail
 VO to Potentiometer
 RS to digital pin 11 of Arduino
 RW to negative rail
 E to digital pin 9 of Arduino
 D4 to digital pin 6 of Arduino
 D5 to digital pin 5 of Arduino
 D6 to digital pin 4 of Arduino
 D7 to digital pin 3 of Arduino
 A to positive rail
 K to negative rail
Other Connections:
 Digital pin 3 of Arduino to push button
 Push button to negative rail
 Potentiometer to negative rail
CHAPTER 4: CODE AND WORKING

4.1: CODE

#include<LiquidCrystal.h>
LiquidCrystal lcd (8,7,6,5,4,3); //RS, E, D4, D5, D6, D7
int ledPin = 13;
int buttonPin = 2;
int ledToggle;
int previousState = HIGH;
unsigned int previousPress;
volatile int buttonFlag;
int buttonDebounce = 20;
int i=0;
int pos=0;
int Speed=100;
String typea = " ## ###### ## #### ####
######## ## ";
15
String typeaa = " ## #### ## #### ## ##
## ";
int typeA[] =
{22,23,32,33,34,35,36,37,43,44,52,53,54,55,61,62,63,64,72,73,74,75,76,
77,78,79,87,88};//28
int typeAA[] =
{17,18,26,27,28,29,40,41,47,48,49,50,58,59,69,70,82,83};//18
void setup()
{
lcd.begin(16,2);
lcd.begin(16,2);
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
attachInterrupt(digitalPinToInterrupt(2), button_ISR, CHANGE);
while(ledToggle==0)
{
16
lcd.clear();
delay(500);
lcd.print(" START GAME ");
delay(500);
}
lcd.clear();
lcd.setCursor(0,0);
lcd.print('O');
//lcd.print(bala.substring(1,3));
}
void loop()
{
while(1)
{
for(i=0;i<89;i++)//
{
if(pos==0)
{
lcd.setCursor(1,0);
lcd.print(typea.substring(i+1,16+i));
}
else
{
lcd.setCursor(0,0);
lcd.print(typea.substring(i,16+i));
}
if(pos==1)
{
lcd.setCursor(1,1);
lcd.print(typeaa.substring(i+1,16+i));
}
else
{
lcd.setCursor(0,1);
18
lcd.print(typeaa.substring(i,16+i));
}
for(int j=0;j<28;j++)
{
if(typeA[j]==i)
{
if(pos==0)
{
gameover();
}
}
}
for(int j=0;j<18;j++)
{
if(typeAA[j]==i)
{
if(pos==1)
19
{
gameover();
}
}
}
delay(Speed);
}
winner();
}
}
void gameover (void)
{
detachInterrupt(digitalPinToInterrupt(2));
while(1)
{
lcd.clear();

delay(500);
lcd.print(" GAME OVER ");
20
delay(500);
}
}
void winner (void)
{
detachInterrupt(digitalPinToInterrupt(2));
while(1)
{
lcd.clear();
delay(500);
lcd.print(" WINNER! WINNER!");
lcd.setCursor(0,1);
lcd.print(" CHICKEN DINNER ");
delay(500);
}
}
void button_ISR()
21
{
buttonFlag = 1;
if((millis() - previousPress) > buttonDebounce && buttonFlag)
{
previousPress = millis();
if(digitalRead(buttonPin) == LOW && previousState == HIGH)
{
ledToggle =! ledToggle;
digitalWrite(ledPin, ledToggle);
previousState = LOW;
if(ledToggle)
{
lcd.setCursor(0,0);
lcd.print('O');
lcd.setCursor(0,1);
lcd.print(' ');
pos=0;
}
22
else
{
lcd.setCursor(0,1);
lcd.print('O');
lcd.setCursor(0,0);
lcd.print(' ');
pos=1;
}
}
else if(digitalRead(buttonPin) == HIGH && previousState == LOW)
{

previousState = HIGH;
}
buttonFlag = 0;
}
}
4.2: WORKING OF FLAPPY BIRD GAME

After making all the connections as per the circuit diagram, upload the code to Arduino and
power on the circuit. The moment you turn on the power supply, the game begins by
displaying “START GAME” on the LCD.

Once the game starts, the Flappy Bird can be toggled its position using the interrupts pin
with the help of the push button. If the bird is in the top, by pressing the button, you can
move it to down and vice – versa.

If the bird touches any of the obstacles, you will lose and the game is over. Since this is a
simple version of the game, there are only a few obstacles and if you successfully overcome
all those obstacles, you will win the game.

.
4.3: OUTPUTS
4.4: GAME PLAY

Flappy Bird is a side-scrolling mobile game featuring 2D retro style graphics. The objective is
to direct a flying bird, named "Faby",who moves continuously to the right, between sets
of Mario-like pipes. If the player touches the pipes, they lose. Faby briefly flaps upward each
time that the player taps the screen; if the screen is not tapped, Faby falls because
of gravity; each pair of pipes that he navigates between earns the player a single point, with
medals awarded for the score at the end of the game.No medal is awarded to scores less
than ten. A bronze medal is given to scores between ten and twenty. In order to receive the
silver medal, the player must reach twenty points. The gold medal is given to those who
score at least thirty points. Players who achieve a score of forty or higher receive a platinum
medal. Android devices enabled the access of world leaderboards, through Google Play.

There is no variation or evolution in gameplay throughout the game, as the pipes always
have the same gap between them and there is no end to the running track, having only the
flap and ding sounds and the rising score as rewards.

4.5: HISTORY
Flappy Bird was created and developed by Nguyen in two to three days. The bird character,
Faby, was originally designed in 2012 for a cancelled platform game. The gameplay was
inspired by the act of bouncing a ping pong ball against a paddle for as long as possible.
Initially the game was significantly easier than it became in the final version, however
Nguyen said he found this version to be boring and subsequently tightened up the difficulty.
He described the business plan of a free download with in-game advertisements as "very
common in the Japanese market".

Nguyen believes that contemporary Western games are overly complex. His company,
dotGears, describes its games as "heavily influenced by retro pixelated games in its golden
age. Everything is pure, extremely hard and incredibly fun to play"

The game is quite simple but interesting and addictive. Using the touch screen we control
the bird and try to avoid the moving pillars which speed increase as we progress. Also the
game can store your highest score even if you unplug the power.

In the previous tutorial (Arduino TFT Tutorial) we learned in details how to use TFT Touch
Screens with an Arduino and we left the game example to be explained in this tutorial. So
now, just like in the previous tutorial, we will step by step explain the code behind this
Arduino Game.
CHAPTER 5: CONCLUSION

A simple DIY style project where we have created a Flappy Bird Game using Arduino, 16×2
LCD Display and a push button. This doesn’t replicate the original Flappy Bird game but
gives an idea on how to implement a simple version on own.

CHAPTER 5.1: REFERENCES

1) https://vishanksinghh.wixsite.com/infinityrun
2) https://www.electronicshub.org/flappy-bird-game-using-arduino

Das könnte Ihnen auch gefallen