JumpMan Game HD44780
JumpMan is very simple game on Arduino. The game uses only two “jump” and “reset” buttons. The game uses a display HD44780 2×16 connected via i2c. In the game, we skip a man over the trees. The speed of the game is growing all the time.
If you do not know how to use the HD44780 display with the i2c module, see the tutorial: HOW TO USE DISPLAY HD44780 i2c .
List elements:
- Arduino Uno
- Display hd44780 and i2c module
- 2 switch
- 7 wires
- universal board
Connections:
HD44780 i2c: SDA to SDA or A4, SCL to SCL or A5, Vcc to 5V, GND to GND
Button 1 to pin RESET and GND
Button 2 to pin 2 digital and GND

Sketch:
Set the address of the i2c module and the size of the display. You can change the amount of live in “int life = 5;” (69 line sketch) .
Control:
button 1 -> Jump
button 2 -> Reset
Enjoy the game 🙂 .
1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
#include <Wire.h> #include <LiquidCrystal_I2C.h> LiquidCrystal_I2C lcd(0x3F,16,2); // Address and Size LCD, #define buttonPin 2 // Game button byte stone[8] = { 0b00100, 0b01110, 0b11111, 0b11111, 0b01110, 0b00100, 0b00100, 0b01110 }; byte armsDown[8] = { 0b00100, 0b01010, 0b00100, 0b00100, 0b01110, 0b10101, 0b00100, 0b01010 }; byte armsUp[8] = { 0b00100, 0b01010, 0b00100, 0b10101, 0b01110, 0b00100, 0b00100, 0b01010 }; byte explosion[8] = { 0b10001, 0b01010, 0b01010, 0b00100, 0b01010, 0b01010, 0b10001, 0b00000 }; byte heart[8] = { 0b00000, 0b01010, 0b11111, 0b11111, 0b01110, 0b00100, 0b00000, 0b00000 }; int stones[16]; int heroY = 2; int heroX = 7; int score = 0; int level=350; int life = 5; // number of lives void setup() { lcd.init(); lcd.backlight(); Serial.begin (9600); randomSeed(analogRead(0)); pinMode(buttonPin, INPUT_PULLUP); int i = 0; for (i = 0; i<16; i++) { stones[i] = 0; } lcd.begin(16, 2); lcd.createChar(0, stone); lcd.createChar(1, armsUp); lcd.createChar(2, armsDown); lcd.createChar(3, explosion); lcd.createChar(4, heart); } void hero() { int buttonValue = digitalRead(buttonPin); int charId = 0; if (buttonValue == LOW) { heroY = 0; charId = 1; } else { heroY = 1; charId = 2; if (stones[heroX] == 1) { charId = 3; life--; score--; } } lcd.setCursor(heroX, heroY); lcd.write((byte)charId); } void moveStones() { int randS = random(0, 2); // shift the stones int i; for (i=1; i<16; i++) { stones[i-1] = stones[i]; } if (randS == 1 && (stones[14] == 1 || stones[13] == 1)) { stones[15] = 0; } else { stones[15] = randS; } for (i = 0; i<16; i++) { if (stones[i] != 0) { lcd.setCursor(i, 1); lcd.write((byte)0); } } } void showLife() { int i; for (i=0; i<life; i++) { lcd.setCursor(i, 0); lcd.write((byte)4); } } void loop() { lcd.clear(); if (life > 0) { moveStones(); hero(); showLife(); score++; level--; } else { lcd.setCursor(2, 0); lcd.print("GAME OVER"); lcd.setCursor(2, 1); lcd.print("Score:"); lcd.print(score); } delay(level); } |