Dodge The Defs!

A simple game using Arduino Uno, 16x2 LCD and a push button.

Jun 24, 2018

13661 views

9 respects

Components and supplies

1

Jumper wires (generic)

1

Pushbutton switch 12mm

2

Resistor 10k ohm

1

Standard LCD - 16x2 White on Blue

1

Arduino UNO

1

Resistor 1k ohm

Project description

Code

lcd_1.ino

arduino

Downloadable files

Complete schematic

Complete schematic

Complete schematic

Complete schematic

Comments

Only logged in users can leave comments

Anonymous user

2 years ago

Apparently i suck :( Great game though

SRP888

2 years ago

Thank you very much😄

scientificcrabs

2 years ago

Hey, quick question about the code, where does it calculate the score?

SRP888

2 years ago

Score is initialized to 0 in line 132. It is incremented by 1 in line 208, which happens every time the player successfully dodges an obstacle.

Anonymous user

2 years ago

Cool Game! Just had a question about the %2, how exactly does it work and what does it do? Thanks

SRP888

2 years ago

%2 returns 1 if the number is odd and 0 if number is even. I am alternating the view of the player based on obstaclePos variable which starts from 15 and reduces by 1 after a certain time interval (obsDelay). So for odd values of obstaclePos like 15,13,11,9,...,1, I show one position for the player and for even values like 14,12,10,8,...,2 I show another position. When you play it in a sequence, it appears like the player is running. You could also use %3 and display 3 different positions, to make the running look smoother.

arohansenroy

2 years ago

Superb game!!😊👍👍

SRP888

2 years ago

Thank you very much😄✌️

Anonymous user

2 years ago

I made this and i loved very much. I was playing it a lot.

SRP888

2 years ago

Thank you very much😄

Anonymous user

2 years ago

What is the tall black button-looking thing in the breadboard?

Anonymous user

2 years ago

That is a potentiometer or a variable resistor.

SRP888

2 years ago

Yes, it is a potentiometer which is used to adjust the contrast of the lcd.

Anonymous user

2 years ago

Wow! I did not expect it to be this good! Amazing what you can do with arduino!

SRP888

2 years ago

Thank you very much😁 By spending enough time, you can do a lot more cool things with it.

geek25

2 years ago

thankyou srp888. this project was easy and i enjoyed the game. well done.

SRP888

2 years ago

Thank you very much😄✌️

Anonymous user

2 years ago

Can anyone please provide the video how does it work?

SRP888

2 years ago

I'm afraid I can't upload a video right now, but where exactly are you facing a difficulty?

Anonymous user

2 years ago

It is so nice...Code is working properly..superb buddy

SRP888

2 years ago

Thank you very much😁

Anonymous user

2 years ago

Looks interesting. Code is clean and compiles perfectly. The problem I'm having is that your schematic does not show the momentary switch button. The photograph is fuzzy on that connection. So my little guy is jumping up and down constantly - not sure yet if that is due to my wiring or possibly some logic issue in the code. Can you clarify? Thanks.

Anonymous user

2 years ago

Thanks - I did figure it out, and realized the pull up resistor had been missed. So it works perfectly now. I remember the day (with Pong and later C-64) that this kind of game was state of the art and a thrill to play.

SRP888

2 years ago

Thank you very much for having a look at this. I'm sorry for not posting a proper schematic, as I already had this image and was too lazy to build it. The problem you are facing is most likely caused because you have connected the resistor of the button to +5V, hence the resistor is 'pulling up'. I did mention in the last line of 'Setting up' that the resistor should be in pull-down mode, i.e. it should be grounded. I'm working on a proper schematic and will upload it soon. Feel free to ask any more questions. Edit: I have updated the schematic, please do have a look. If it still isn't working try rotating your button by 90 degrees.

linglinglingling

2 years ago

good idea

geek25

3 years ago

thankyou srp888. this project was easy and i enjoyed the game. well done.

SRP888

2 years ago

Thank you very much😄✌️

scientificcrabs

3 years ago

Hey, quick question about the code, where does it calculate the score?

SRP888

2 years ago

Score is initialized to 0 in line 132. It is incremented by 1 in line 208, which happens every time the player successfully dodges an obstacle.

Anonymous user

4 years ago

Cool Game! Just had a question about the %2, how exactly does it work and what does it do? Thanks

SRP888

2 years ago

%2 returns 1 if the number is odd and 0 if number is even. I am alternating the view of the player based on obstaclePos variable which starts from 15 and reduces by 1 after a certain time interval (obsDelay). So for odd values of obstaclePos like 15,13,11,9,...,1, I show one position for the player and for even values like 14,12,10,8,...,2 I show another position. When you play it in a sequence, it appears like the player is running. You could also use %3 and display 3 different positions, to make the running look smoother.

arohansenroy

4 years ago

Superb game!!😊👍👍

SRP888

2 years ago

Thank you very much😄✌️

David646

6 years ago

Thank you so much! Perfect project! I used I2c to reduce the LCD connections, and used only 1 resistor for the button.

SRP888

2 years ago

Thank you very much😁

yashadayal

6 years ago

Can anyone please provide the video how does it work?

SRP888

2 years ago

I'm afraid I can't upload a video right now, but where exactly are you facing a difficulty?

Aedan_Barr

6 years ago

I made this and i loved very much. I was playing it a lot.

SRP888

2 years ago

Thank you very much😄

Anonymous user

6 years ago

Apparently i suck :( Great game though

SRP888

2 years ago

Thank you very much😄

Anonymous user

6 years ago

Wow! I did not expect it to be this good! Amazing what you can do with arduino!

SRP888

2 years ago

Thank you very much😁 By spending enough time, you can do a lot more cool things with it.

thetalkingjeff

7 years ago

What is the tall black button-looking thing in the breadboard?

SRP888

2 years ago

Yes, it is a potentiometer which is used to adjust the contrast of the lcd.

Anonymous user

2 years ago

That is a potentiometer or a variable resistor.

Anonymous user

7 years ago

It is so nice...Code is working properly..superb buddy

SRP888

2 years ago

Thank you very much😁

Anonymous user

7 years ago

Looks interesting. Code is clean and compiles perfectly. The problem I'm having is that your schematic does not show the momentary switch button. The photograph is fuzzy on that connection. So my little guy is jumping up and down constantly - not sure yet if that is due to my wiring or possibly some logic issue in the code. Can you clarify? Thanks.

Anonymous user

2 years ago

Thanks - I did figure it out, and realized the pull up resistor had been missed. So it works perfectly now. I remember the day (with Pong and later C-64) that this kind of game was state of the art and a thrill to play.

SRP888

2 years ago

Thank you very much for having a look at this. I'm sorry for not posting a proper schematic, as I already had this image and was too lazy to build it. The problem you are facing is most likely caused because you have connected the resistor of the button to +5V, hence the resistor is 'pulling up'. I did mention in the last line of 'Setting up' that the resistor should be in pull-down mode, i.e. it should be grounded. I'm working on a proper schematic and will upload it soon. Feel free to ask any more questions. Edit: I have updated the schematic, please do have a look. If it still isn't working try rotating your button by 90 degrees.