Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <LiquidCrystal.h>
- LiquidCrystal lcd(8, 9, 4, 5, 6, 7);
- int x = 7; // max x = 14
- int y = 0; // max y = 1
- //int captcha = 0;
- String smileys[15] = {"A", "N","A","V","O","L","I","M","I","L","O","V","A","N","A"};
- byte ocitaj_taster()
- {
- int tmp = analogRead(0); //stanje tastera se ocitava preko
- //analognog ulaza 0
- if (tmp > 635 && tmp < 645) //SELECT
- return 1;
- if (tmp > 405 && tmp < 415) //LEFT
- return 2;
- if (tmp > 95 && tmp < 105) //UP
- return 3;
- if (tmp > 252 && tmp < 262) //DOWN
- return 4;
- if (tmp < 5) //RIGHT
- return 5;
- return 0; //nije pritisnut nijedan od tastera
- }
- int rez = 0;
- void setup() {
- lcd.begin(16,2);
- lcd.setCursor(x,y);
- lcd.print("<3");
- }
- void loop() {
- int key = ocitaj_taster();
- delay(300);
- //if(captcha == 1) {
- switch(key){
- case 2:
- if( x > 0 && x <= 14) {
- x--;
- }
- break;
- case 3:
- if( y == 1) {
- y--;
- }
- break;
- case 4:
- if( y == 0) {
- y++;
- }
- break;
- case 5:
- if( x >= 0 && x < 14) {
- x++;
- }
- break;
- }
- //}
- lcd.clear();
- lcd.setCursor(x,y);
- lcd.print(smileys[x]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement