Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <LiquidCrystal.h>
  2.  
  3. // initialize the library by associating any needed LCD interface pin
  4. // with the arduino pin number it is connected to
  5. LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
  6. volatile int x = 0;
  7. volatile int y = 0;
  8. byte heart[8] = {
  9.     0b00000,
  10.     0b01010,
  11.     0b11111,
  12.     0b11111,
  13.     0b11111,
  14.     0b01110,
  15.     0b00100,
  16.     0b00000
  17. };
  18. byte smile[8]= {
  19.     0B00001,
  20.     0B00000,
  21.     0B00001,
  22.     0B00000,
  23.     0B00001,
  24.     0B00000,
  25.     0B00001,
  26.     0B00000,
  27. };
  28. // смайлик
  29. byte smiley[8] = {
  30.     0b00000,
  31.     0b00000,
  32.     0b01010,
  33.     0b00000,
  34.     0b00000,
  35.     0b10001,
  36.     0b01110,
  37.     0b00000
  38. };
  39.  
  40. byte frownie[8] = {
  41.     0b00000,
  42.     0b00000,
  43.     0b01010,
  44.     0b00000,
  45.     0b00000,
  46.     0b00000,
  47.     0b01110,
  48.     0b10001
  49. };
  50.  
  51. byte armsDown[8] = {
  52.     0b00100,
  53.     0b01010,
  54.     0b00100,
  55.     0b00100,
  56.     0b01110,
  57.     0b10101,
  58.     0b00100,
  59.     0b01010
  60. };
  61.  
  62. byte armsUp[8] = {
  63.     0b00100,
  64.     0b01010,
  65.     0b00100,
  66.     0b10101,
  67.     0b01110,
  68.     0b00100,
  69.     0b00100,
  70.     0b01010
  71. };
  72. byte cube[8] =
  73. {
  74.     0B00000,
  75.     0B00000,
  76.     0B11111,
  77.     0B11111,
  78.     0B11111,
  79.     0B11111,
  80.     0B00000,
  81.     0B00000,
  82. };
  83. void setup() {
  84.     lcd.begin(16, 2);
  85.  
  86.     // создаём новый символ сердечка
  87.     lcd.createChar(0, heart);
  88.     // создаём новый символ смайлика
  89.     lcd.createChar(1, smiley);
  90.     // создаём новый символ
  91.     lcd.createChar(2, frownie);
  92.     // создаём новый символ
  93.     lcd.createChar(3, armsDown);
  94.     // создаём новый символ
  95.     lcd.createChar(4, armsUp);
  96.     lcd.createChar(5, smile);
  97.     lcd.createChar(6, cube);
  98.     // устанавливаем курсор в левый верхний угол
  99.     lcd.setCursor(x, y);
  100.  
  101.     // выводим сообщение
  102.     // lcd.print("I ");
  103.     lcd.write(byte(6)); // when calling lcd.write() '0' must be cast as a byte
  104.     //  delay(500);
  105.     //   lcd.clear();
  106.     //lcd.print(" Arduino! ");
  107.     //lcd.write((byte)1);
  108.  
  109. }
  110. int time =220;
  111. void loop() {
  112.     if (14<x) {
  113.         ::x=-1;
  114.         ::y++;
  115.         lcd.write(byte(6));
  116.     }
  117.  
  118.     if (1<y) {
  119.         ::x=-1;
  120.         ::y=0;
  121.         lcd.write(byte(6));
  122.     }
  123.     int m;
  124.     m = analogRead (0);
  125.     lcd.setCursor(0,0);
  126.  
  127.     if (m < 60) {
  128.         lcd.print ("Right  ");
  129.         lcd.clear();
  130.         ::x++;
  131.         lcd.setCursor(x, y);
  132.         lcd.write(byte(6));
  133.         delay(time);
  134.     }
  135.     else if (m < 200) {
  136.         //lcd.print ("Up    ");
  137.         lcd.clear();
  138.         ::y--;
  139.         lcd.setCursor(x, y);
  140.         lcd.write(byte(6));
  141.         delay(time);
  142.     }
  143.     else if (m < 400) {
  144.         //lcd.print ("Down  ");
  145.         lcd.clear();
  146.         ::y++;
  147.         lcd.setCursor(x, y);
  148.         lcd.write(byte(6));
  149.         delay(time);
  150.     }
  151.     else if ( m < 600) {
  152.         //lcd.print ("Left  ");
  153.         lcd.clear();
  154.         ::x--;
  155.         lcd.setCursor(x, y);
  156.         lcd.write(byte(6));
  157.         delay(time);
  158.     }
  159.     else if (m < 800) {
  160.         //lcd.print ("Select");
  161.         lcd.clear();
  162.         lcd.setCursor(0, 0);
  163.         lcd.write(byte(6));
  164.     }
  165. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement