Two player HD44780 Arduino Pong

I know it's not as cool as a lot of the projects on here, but it's one of my first so I don't care :smiley:

I use a 204 HD44780 compatible display and the (8 bit currently, 4 bit later) LiquidCrystal library that has been slightly modified to work with my 204 display.

"Screen" terminal application transmits 'w' and 's' for player one and 'o' and 'l' for player two via serial, and the arduino does the processing.

Images:


Code/howto on request. :slight_smile:

it's not as cool as a lot of the projects on here

No need to apologise, you've done it and it is great thanks for sharing it.

There is nothing like the kick you get from your first project, the projects may get better but the kick remains the same. :slight_smile:

That does look cool. So you play by hitting keys on the laptop right?

Yes. It could just as easily be done with buttons though :slight_smile:
At the moment it's sent via serial and then the arduino performs the movements etc.
Using the linux command "screen /dev/ttyUSB0" (or wherever your arduino device is) you can effectively transmit all your terminal input to the arduino and have all the arduino's serial output displayed in the terminal window.

That is awesome, I just got mine last week, I would have to see the how-to and code for this project.

Thanks
Ted

Do you have to mod the LiquidCrystal library for 4 * 20 LCD display?

If so, can you post the mod?

I'm developing a program for 4 * 20s...but don't currently have the hardware all up and running (or existing) at the moment. So i can't test it.

Cheers, Ben

The modification that I made to the LiquidCrystal library was minimal, updating the old method with this:

void LiquidCrystal::setCursor(int col, int row)
{
  int row_offsets[] = { 0x00, 0x14 , 0x40, 0x54 };
  command(0x80 | (col + row_offsets[row]));
}

I also wrote a method in my code for outputting text, but I seem to have misplaced it. I called it "fixedWrite" and it took a byte (char).

It looked something like this:

int column = 0;
int row = 0;

void fixedWrite(byte input){
  if(column==19){
    // you're at the end
    column = 0;
    row++;
  }
  if(row==4){
    row=0;
  }
  lcd.setCursor(column, row);
  lcd.write(input);
}

(I wrote that from memory, so if there are mistakes I appologise!)

That was used when reading characters from the console and printing them to the LCD screen, one char at a time.

*edited: swapped "char input" for "byte input"

Alright, cheers.

I'll test that out when i can and i'll put up some of my code if anyone is interested (when i've tested it all).

How would this project go with a Serial LCD?

The reason that I edited the setCursor function is that when I output the data using the old library it wrote to the first line, then the third, then the second, then the fourth - which was a bit annoying :smiley:

@scootabug: If you wanted to use a Serial LCD I expect you would then use the Wire library instead of the LiquidCrystal one. My program takes data and formats/outputs it using the LiquidCrystal library into a form the LCD can understand. Serial LCDs already have that build inside of them, you just need to send a character over serial. Take a look here: http://arduino.cc/en/Reference/Wire

Wouldn't you just require the normal serial ouput? And there's a library for using serial on any Arduino pins.