Trybotics Logo

Simple Arduino LCD Game!

DESCRIPTION

Hello World! Pure Carbon here and today I will be showing you how to make an extremely simple game that can be played on an LCD Button Shield for Arduino. Unfortunately its not actually a game because all you will be able to do is make a character walk back and forth using the buttons on the shield and in order for something to be considered a game in my opinion there need to be some sort of objective or goal to work towards. The sketch that I created was modified from the example code that can be found here. I made a video going through the code where I explain what everything does, so enjoy you silly humans!

Video:

important announcement: I was recently sent some really neat items from this cool website called 1 Byone.com which I will be doing a review on in the future, so be sure to keep an eye out for that. This website also sells tons of really cool things like phone accessories, speakers, stage lights, as well as many other really cool things. So be sure to check that out!

Thank you for all your support, and tips to help me improve my Instructables. Without you guys I wouldn't be doing this right now, you can expect many more Instructables in the future so don't forget to follow me and/or favorite this Instructable. If you have any question or concerns then be sure to comment, or if you just want tell me how awesome this is, that's fine too! Here it is, hope you enjoy it and once again thank you.

Check me out on: YouTube: https://www.youtube.com/channel/UCp1Iy_qqZl-TBWrw...

Channel ad:

Facebook: https://www.facebook.com/Pure-Carbon-398550910296...

Twitter: https://www.facebook.com/Pure-Carbon-398550910296...

Also Support me on Patreon where contributors get early access to all the videos I make along with free PDF downloads of all my upcoming Instructables: https://www.facebook.com/Pure-Carbon-398550910296...

Description:

Here are the items you will need to do this project:

Description:

Now copy and paste the following code into the Arduino IDE, plug in the Arduino to your computer, adjust the settings (board, port, etc.) And upload the sketch to the board. Keep in mind there my be a few things that you need to adjust like the spacing. If you have any problems then leave a comment down below an I will do my best to help you out.

///////////////////////////////////////////////////////////////////////////////////////////////////

#include

LiquidCrystal lcd(8, 13, 9, 4, 5, 6, 7);

int lcd_key = 0;

int adc_key_in = 0;

#define btnRIGHT 0

#define btnLEFT 3

#define btnNONE 5

int read_LCD_buttons()

{ adc_key_in = analogRead(0);

if (adc_key_in < 50) return btnRIGHT;

if (adc_key_in < 650) return btnLEFT;

return btnNONE;

}

byte mario1 [8] = {

B01110,

B11111,

B01110,

B11111,

B01110,

B01010,

B10001,

};

byte mario2 [8] = {

B01110,

B11111,

B01110,

B11111,

B01110,

B00100,

B00100,

};

void marioStand (){

lcd.write((byte)0);

}

void marioRun (){

lcd.setCursor(3,1);

lcd.write((byte)0);

delay(300);

lcd.setCursor(3,1);

lcd.write((byte)1);

delay(300);

}

void setup() {

lcd.begin(16, 2);

lcd.createChar(0,mario1);

lcd.createChar(1,mario2);

}

void loop() {

lcd.setCursor(3,1);

lcd_key = read_LCD_buttons();

switch (lcd_key)

{

case btnRIGHT:

{

marioRun();

lcd.scrollDisplayRight();

break;

}

case btnLEFT:

{

marioRun();

lcd.scrollDisplayLeft();

break;

}

default:

marioStand();

break;

}

}

Description:

Now you're done! To control your character press either the button labeled left or right and you should see your character move one space for every time you press one of those buttons.

Like I said earlier if you have any comments, questions, or concerns then leave them in the comment section down below and I will be more than happy to respond. If you like this then please be sure to subscribe to me here and to my YouTube channel for more awesome content like this. there is link on my page to it so be sure to check it out. Thank you for checking out my Instructable and be sure to favorite it, once again thank you.

Description:


YOU MIGHT ALSO LIKE