Vous êtes sur la page 1sur 26

ARDUINO LCD GAME

A MINI PROJECT REPORT

Submitted by

ARAV IND M

16TUEC013

ASHW IN M

16TUEC020

BALA VRUTHISH S

16TUEC023

In parti al fulfilment for the award of the degr ee of B ACHELOR OF ENGINEERING

in ELECTRONIC S AND COMMUNICATION ENGI NEERING

ENGINEERING in ELECTRONIC S AND COMMUNICATION ENGI NEERING SRI KRI SHNA COLLEGE OF TECHNOLO GY (An

SRI KRI SHNA COLLEGE OF TECHNOLO GY

(An autonomou s institution affiliated to Anna University, Chennai Accr edited by NBA & NAAC with ‘A’ Grade)

K ovaipudur, Coimbatore-641042.

MARCH – 2019

1

BONAFIDE CERTIFICATE

Certified this mini project report “ARDUINO LCD GAME” is the bonafide work of “ARAVIND.M, ASHWIN.M, BALAVRUTHISH.S ”, who carried out the mini project work under my supervision.

SIGNATURE Dr. R. UDAIYA KUMAR ,M.E.,Ph.D, HEAD OF THE DEPARTMENT Professor and Head, Department of Electronics and Communication Engineering Sri Krishna College of Technology,

Coimbatore-640142 Coimbatore-641042

SIGNATURE Mr. S. GANESH PRABHU,M.E., SUPERVISOR Assistant Professor, Department of Electronics and Communication Engineering Sri Krishna College of Technology,

Certified

that

the

candidates

were

examined

by

us

in

Viva-Voce

examination

held

on

……………………. at Sri Krishna College of Technology, Coimbatore – 641042.

…………………………

Internal Examiner

2

………………………

External Examiner

ACKNOWLEDGEMENT

Firstand foremost, we bow our head to the ALMIGHTY for being our light and for his gracious showers of blessings throughout the course of this mini project.

We express our cordial thanks to Dr.BALAMURGAN, M.E., Ph.D., Principal, Sri Krishna College of Technology, for providing all the facilities to carry out this mini project work.

We record our genuine gratitude and respect to our Head of the Department, Dr.R.UDAIYAKUMAR, M.E., Ph.D., Department of Electronics and Communication Engineering, Sri Krishna College of Technology, for his noble attention and eminent guidance throughout the mini project work.

We are greatly indebted to our mini project coordinator Ms.R.PRIYA M.E., Assistant Professor, Electronics and Communication, Sri Krishna College of Technology, Coimbatore and to our mini project guide Mr.S.GANESH PRABHU M.E., Assistant Professor, for her exigent comments, inspirational guidance and invaluable suggestion in every respect for the completion of our mini project work.

We express our deepest thanks to all other staff members and programmers for their valuable suggestion and all help during study. Finally, we whole-heartedly thank our parents and friends who have provided us valuable inputs in the improvement of our mini project.

3

CHAPTER

NO.

Table of Contents

TITLE

PAGE NO

ABSTRACT

5

LIST OF FIGURES

6

1. INTRODUCTION

7

2. COMPONENTS

7

2.1. COMPONENTS REQUIRED

7

2.2. DETAILED DESCRIPTION OF THE

8

COMPONENTS

3. CIRCUIT

11

3.1. CIRCUIT DESIGN

11

3.2. CIRCUIT DIAGRAM

13

4. CODE AND OUTPUTS

14

4.1. ARDUINO CODE

14

4.2. OUTPUTS

24

5. CONCLUSION

25

5.1.

REFERENCE

26

4

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.

5

LIST OF FIGURES

S.NO

FIGURE NAME

PAGE NO

1

ARDUINO UNO

10

2

16X2 LCD DISPLAY

11

3

CIRCUIT DIAGRAM

13

4

OUTPUT 1

24

5

OUTPUT 2

24

6

OUTPUT 3

25

6

1. INTRODUCTION

The main concept of the Flappy Bird Game using Arduino is

very simple. We have replicated the bird with the character “0” and

the obstacles with s string of the character “#”.Actually, we 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.

2.COMPONENTS

2.1 COMPONENTS REQUIRED

Arduino UNO

7

16×2 LCD Display

Push Button

Connecting Wires

Breadboard

5V Power Supply

2.2 DETAILED DESCRIPTION OF COMPONENTS

ARDUINO UNO:

The Arduino UNO is an open-source microcontroller board based

on

the Microchip ATmega328P microcontroller

and

developed

by

Arduino.cc. The board is equipped with sets of digital and analog

input/output (I/O) pins that may be interfaced to various expansion

boards (shields) and other circuits. The board has 14 Digital pins, 6

Analog

pins,

and

programmable

with

the Arduino

IDE

(Integrated

Development Environment) via a type B USB cable. It can be powered

8

by a USB cable or by an external 9 volt battery, though it accepts

voltages between 7 and 20 volts. It is also similar to the Arduino Nano

and

Leonardo. The

hardware

reference

design

is

distributed

under

a Creative Commons Attribution Share-Alike 2.5 license and is available

on the Arduino website. Layout and production files for some versions

of the hardware are also available. "Uno" means one in Italian and was

chosen to mark the release of Arduino Software (IDE) 1.0. The Uno

board and version 1.0 of Arduino Software (IDE) were the reference

versions of Arduino, now evolved to newer releases. The Uno board is

the first in a series of USB Arduino boards, and the reference model for

the Arduino platform. The ATmega328 on the Arduino Uno comes

preprogrammed with a bootloader that allows uploading new code to it

without the use of an external hardware programmer. It communicates

using the original STK500 protocol. The Uno also differs from all

preceding boards in that it does not use the FTDI USB-to-serial driver

chip. Instead, it uses the Atmega16U2 (Atmega8U2 up to version R2)

programmed as a USB-to-serial converter.

9

16x2 LCD: An LCD is an electronic display module which uses liquid crystal to produce

16x2 LCD:

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. The 16×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.

10

3.CIRCUIT 3.1 CIRCUIT DESIGN Basic Connections: • connect 5v pin of Arduino to positive rail

3.CIRCUIT

3.1 CIRCUIT DESIGN

Basic Connections:

connect 5v pin of Arduino to positive rail of breadboard

11

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

12

3.2 CIRCUIT DIAGRAM

3.2 CIRCUIT DIAGRAM 13

13

4.CODE AND OUTPUT

4.1 ARDUINO 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

= "

##

######

##

####

####

########

##

";

14

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)

{

15

lcd.clear();

delay(500);

lcd.print("

delay(500);

}

lcd.clear();

START GAME

");

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);

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)

{

gameover();

}

}

}

delay(Speed);

}

winner();

}

}

void gameover (void)

{

detachInterrupt(digitalPinToInterrupt(2));

while(1)

{

lcd.clear();

delay(500);

lcd.print("

GAME OVER

");

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()

{

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;

}

21

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;

}

}

22

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.

23

4.2 OUTPUTS

4.2 OUTPUTS 24
4.2 OUTPUTS 24

24

5.CONCLUSION A simple DIY style project where we have created a Flappy Bird Game using

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.

25

5.1 REFERENCES

1) https://vishanksinghh.wixsite.com/infinityrun

2) https://www.electronicshub.org/flappy-bird-game-using-arduino

26