Truck Lane - a 16x2 LCD Arduino Game

17,936

12

15

Published

Introduction: Truck Lane - a 16x2 LCD Arduino Game

About: Sucks at soldering, [hopefully] compensates with coding.

Code: http://bit.ly/lcdtrucks
I was fooling around with the createChar() function to create cars.
How Sinclair ZX Spectrum :) Cars are small, so it's better to view them in full screen mode.
I'm using an Electronic Brick display (long story), but any Hitachi HD44780 compatible would do.

Share

    Recommendations

    • Casting Contest

      Casting Contest
    • Woodworking Contest

      Woodworking Contest
    • Planter Challenge

      Planter Challenge
    user

    We have a be nice policy.
    Please be positive and constructive.

    Tips

    Questions

    15 Comments

    hi, there. It's such an interesting game. Would you mind if I add it to my tutorial as an example?

    1 reply

    Hi.

    If what you're doing is not commercial, all you need to do is give me credit by linking here and to the license. If it's commercial - I'd like to know more ;)

    Anyway, note that "Truck Lane" is not a full instructable (e.g. there are no schematics). Perhaps Ariadne and/or Marble Disorder are more suitable for a tutorial.

    Once your tutorial is ready, please send me a link.

    All the best,

    The Dod.

    It was so cool!

    It was so cool!

    It was so cool!

    Great Arduino game. Oh I connected a 10k potentiometer to A1 and my 16x2 display is connected to my uno using IIC/I2C/TWI/SPI Serial Interface on pin 4 and 5. Works great. Beside resetting the unit, how to restart game.

    you need to do these changes to use the serial interface

    remove

    #include <LiquidCrystal.h>

    LiquidCrystal lcd(2, 3, 4, 5, 6, 7, 8);

    add

    #include <Wire.h>
    #include <LiquidCrystal_I2C.h> //need to downed if you don't have it

    LiquidCrystal_I2C lcd(0x27,16,2);

    change

    const int POTPIN = 1;

    to

    const int POTPIN = A1;

    in void setup()

    add

    lcd.init(); // initialize the lcd
    lcd.backlight(); //add this if you want backlight

    in all I used 8 wires for this game. I not sure can I use a 0.5 watt 8 ohm speaker for a Piezo speaker so I left that out.

    Works great

    What other pin setups can use. I have a joy stick sheild by sparkfun. https://www.sparkfun.com/tutorials/171 and it needs a lot of pins. I have 13 to 7 open and A2 to A5 open. I cant seem to make it run the program, I changed "LiquidCrystal lcd(12, 11, 5, 4, 3, 2);"to" LiquidCrystal lcd(12,11,10,9,8,7). any ideas??

    The type of lcd display does not really matter does it?

    Can you provide the circuit diagram pleaase???

    1 reply

    It's quite similar to the one at Ariadne: https://www.instructables.com/id/Ariadne-a-1st-person-maze-on-a-16x2-LCD/#step1
    The only differences is that Ariadne also has a push button.
    Ariadne also comes with a pde file (Truck Lane also had one, but I guess I've lost it :) ), and is much more fun to play.

    nice work, how can i do a similar job on a pic18f4550 , using a 128 x64 lcd.

    2 replies

    Thanks.
    Re pic: I've never tried working on anything less user-friendly than an Arduino. I'm a coder, not a warrior :) but it shouldn't be hard.
    As for 128x64 LCD: when you have real pixel-level graphics [IMHO] you don't need to resort to font glyphs.
    Trying to imitate truck lane would be aiming too low when you can place the obstacles (trucks, trees, etc.) on a grid of 64 instead of 5. You can easiily do a ski game with trees (maybe a few moving skiers). Looks more impressive and is a lot more fun to play.

    yes the ski game sounds cool, but whats crazy is how you made a scrolling game on an small lcd. anyway, i'm attempting snake at the moment but i dont know if the ski game your mentioned would be easier to implement on my system. i can move pixels and shapes on screen successfully . i just need the algorithm for moving objects and detecting collisions as you've done in your game.