Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- // initialize the library by associating any needed LCD interface pin
- // with the arduino pin number it is connected to
- LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
- volatile int x = 0;
- volatile int y = 0;
- byte heart[8] = {
- 0b00000,
- 0b01010,
- 0b11111,
- 0b11111,
- 0b11111,
- 0b01110,
- 0b00100,
- 0b00000
- };
- byte smile[8]= {
- 0B00001,
- 0B00000,
- 0B00001,
- 0B00000,
- 0B00001,
- 0B00000,
- 0B00001,
- 0B00000,
- };
- // смайлик
- byte smiley[8] = {
- 0b00000,
- 0b00000,
- 0b01010,
- 0b00000,
- 0b00000,
- 0b10001,
- 0b01110,
- 0b00000
- };
- byte frownie[8] = {
- 0b00000,
- 0b00000,
- 0b01010,
- 0b00000,
- 0b00000,
- 0b00000,
- 0b01110,
- 0b10001
- };
- byte armsDown[8] = {
- 0b00100,
- 0b01010,
- 0b00100,
- 0b00100,
- 0b01110,
- 0b10101,
- 0b00100,
- 0b01010
- };
- byte armsUp[8] = {
- 0b00100,
- 0b01010,
- 0b00100,
- 0b10101,
- 0b01110,
- 0b00100,
- 0b00100,
- 0b01010
- };
- byte cube[8] =
- {
- 0B00000,
- 0B00000,
- 0B11111,
- 0B11111,
- 0B11111,
- 0B11111,
- 0B00000,
- 0B00000,
- };
- void setup() {
- lcd.begin(16, 2);
- // создаём новый символ сердечка
- lcd.createChar(0, heart);
- // создаём новый символ смайлика
- lcd.createChar(1, smiley);
- // создаём новый символ
- lcd.createChar(2, frownie);
- // создаём новый символ
- lcd.createChar(3, armsDown);
- // создаём новый символ
- lcd.createChar(4, armsUp);
- lcd.createChar(5, smile);
- lcd.createChar(6, cube);
- // устанавливаем курсор в левый верхний угол
- lcd.setCursor(x, y);
- // выводим сообщение
- // lcd.print("I ");
- lcd.write(byte(6)); // when calling lcd.write() '0' must be cast as a byte
- // delay(500);
- // lcd.clear();
- //lcd.print(" Arduino! ");
- //lcd.write((byte)1);
- }
- int time =220;
- void loop() {
- if (14<x) {
- ::x=-1;
- ::y++;
- lcd.write(byte(6));
- }
- if (1<y) {
- ::x=-1;
- ::y=0;
- lcd.write(byte(6));
- }
- int m;
- m = analogRead (0);
- lcd.setCursor(0,0);
- if (m < 60) {
- lcd.print ("Right ");
- lcd.clear();
- ::x++;
- lcd.setCursor(x, y);
- lcd.write(byte(6));
- delay(time);
- }
- else if (m < 200) {
- //lcd.print ("Up ");
- lcd.clear();
- ::y--;
- lcd.setCursor(x, y);
- lcd.write(byte(6));
- delay(time);
- }
- else if (m < 400) {
- //lcd.print ("Down ");
- lcd.clear();
- ::y++;
- lcd.setCursor(x, y);
- lcd.write(byte(6));
- delay(time);
- }
- else if ( m < 600) {
- //lcd.print ("Left ");
- lcd.clear();
- ::x--;
- lcd.setCursor(x, y);
- lcd.write(byte(6));
- delay(time);
- }
- else if (m < 800) {
- //lcd.print ("Select");
- lcd.clear();
- lcd.setCursor(0, 0);
- lcd.write(byte(6));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement