Skip to content

Instantly share code, notes, and snippets.

@cbscribe
Created April 20, 2021 03:46
Show Gist options
  • Save cbscribe/e96f6fab743ae2c2c9dd0ad371ac1e2d to your computer and use it in GitHub Desktop.
Save cbscribe/e96f6fab743ae2c2c9dd0ad371ac1e2d to your computer and use it in GitHub Desktop.
Arduino+LCD Pacman example
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
byte pacman1[] = {
B01110,
B11111,
B11011,
B11111,
B11100,
B11111,
B11111,
B01110
};
byte pacman2[] = {
B01110,
B11111,
B11011,
B11111,
B11111,
B11111,
B11111,
B01110
};
byte ghost[] = {
B01110,
B11111,
B11111,
B10101,
B11111,
B11111,
B11111,
B10101
};
void setup()
{
lcd.begin(16, 2);
lcd.createChar(1, pacman1);
lcd.createChar(2, pacman2);
lcd.createChar(3, ghost);
}
int x = 0;
void loop()
{
lcd.setCursor(x-2, 0);
lcd.write(3);
lcd.setCursor(x, 0);
lcd.write(1);
delay(100);
lcd.setCursor(x, 0);
lcd.write(2);
delay(100);
x++;
if (x > 18)
{
x = 0;
}
lcd.clear();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment