Advertisement
ChaOSzz

Untitled

May 26th, 2022
931
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <LiquidCrystal.h>
  2.  
  3. LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
  4.  
  5. byte kriper[2][8] =
  6. {
  7.   {
  8.     0b00000,
  9.     0b01110,
  10.     0b01110,
  11.     0b00100,
  12.     0b00100,
  13.     0b00100,
  14.     0b01010,
  15.     0b01010
  16.   },
  17.   {
  18.     0b00000,
  19.     0b00000,
  20.     0b01110,
  21.     0b01110,
  22.     0b00100,
  23.     0b00100,
  24.     0b01010,
  25.     0b10001
  26.   }
  27. };
  28.  
  29. int px,py;
  30.  
  31. void setup()
  32. {
  33.   pinMode(A0,INPUT);
  34.   pinMode(A1,INPUT);
  35.   pinMode(A2,INPUT);
  36.   pinMode(A3,INPUT);
  37.    
  38.   lcd.createChar(0,kriper[0]);
  39.   lcd.createChar(1,kriper[1]);
  40.  
  41.  
  42.   lcd.begin(16, 2);
  43.   Serial.begin(9600);
  44.  
  45.   px = 0; py = 0;
  46. }
  47.  
  48. void loop()
  49. {
  50.  
  51.   if(digitalRead(A0) == 1 && px>0)
  52.   {
  53.     px--;
  54.     draw(px,py);
  55.   }
  56.   if(digitalRead(A1) == 1)py = 1;
  57.  
  58.   if(digitalRead(A3) == 1 && px <= 15)
  59.   {
  60.     draw(px,py);
  61.     px++;
  62.   }
  63.   if(digitalRead(A2) == 1)py = 0;
  64.  
  65.   Serial.print("X: ");Serial.print(px);Serial.print("Y: ");Serial.println(py);
  66.   draw(px,py);
  67.  
  68. }
  69.  
  70. void draw(int x, int y)
  71. {
  72.    lcd.setCursor(x,y);
  73.    lcd.write(byte(0));
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement