Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- byte kriper[2][8] =
- {
- {
- 0b00000,
- 0b01110,
- 0b01110,
- 0b00100,
- 0b00100,
- 0b00100,
- 0b01010,
- 0b01010
- },
- {
- 0b00000,
- 0b00000,
- 0b01110,
- 0b01110,
- 0b00100,
- 0b00100,
- 0b01010,
- 0b10001
- }
- };
- int px,py;
- void setup()
- {
- pinMode(A0,INPUT);
- pinMode(A1,INPUT);
- pinMode(A2,INPUT);
- pinMode(A3,INPUT);
- lcd.createChar(0,kriper[0]);
- lcd.createChar(1,kriper[1]);
- lcd.begin(16, 2);
- Serial.begin(9600);
- px = 0; py = 0;
- }
- void loop()
- {
- if(digitalRead(A0) == 1 && px>0)
- {
- px--;
- draw(px,py);
- }
- if(digitalRead(A1) == 1)py = 1;
- if(digitalRead(A3) == 1 && px <= 15)
- {
- draw(px,py);
- px++;
- }
- if(digitalRead(A2) == 1)py = 0;
- Serial.print("X: ");Serial.print(px);Serial.print("Y: ");Serial.println(py);
- draw(px,py);
- }
- void draw(int x, int y)
- {
- lcd.setCursor(x,y);
- lcd.write(byte(0));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement