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 analogPin = 0;
- int val = 0;
- void setup ()
- {
- Serial.begin (9600) ;
- lcd.begin(16, 2);
- lcd.setCursor(0,0);
- lcd.cursor();
- lcd.noBlink();
- }
- int procitajTaster(int val) {
- if (val > 620 && val < 660)return 1;
- else if (val > 390 && val < 430)return 2;
- else if (val > 80 && val < 120)return 3;
- else if (val > 245 && val < 275)return 4;
- else if ( val < 20 && val > -20)return 5;
- else return 0;
- }
- char currChar = 'A';
- int trenutniPolozajSlova = 0;
- int prosliPolozaj = 0;
- int modUpisa(int stanje){
- switch(stanje){
- case 1:if(prosliPolozaj == 0)return 1;
- prosliPolozaj = 1;
- break;
- case 2:if(prosliPolozaj == 0){trenutniPolozajSlova--; currChar = '@';}
- prosliPolozaj = 2;
- break;
- case 3:if(prosliPolozaj == 0){if(currChar == '@'){lcd.print(' ');currChar++;}else {lcd.print(currChar);currChar++;}}
- prosliPolozaj = 3;
- break;
- case 4:if(prosliPolozaj == 0){if(currChar == '@'){lcd.print(' ');currChar--;}else {lcd.print(currChar);currChar--;}}
- prosliPolozaj = 4;
- break;
- case 5:if(prosliPolozaj == 0){trenutniPolozajSlova++; currChar = '@';}
- prosliPolozaj = 5;
- break;
- default:
- prosliPolozaj = 0;
- }
- lcd.setCursor(trenutniPolozajSlova,0);
- return 0; }
- int pomeranjeDispleja = 0;
- int iteracija = 0;
- int modPrezentacije(int stanje){
- lcd.noCursor();
- if(pomeranjeDispleja == 0){if(!(iteracija%20))lcd.scrollDisplayLeft();iteracija++;if(iteracija==140)pomeranjeDispleja = 1;}
- else {if(!(iteracija%20))lcd.scrollDisplayRight();iteracija--;if(iteracija==-140)pomeranjeDispleja = 0;}
- delay(15);
- }
- int mod = 0;
- void loop ()
- {
- lcd.print(currChar);
- while(1){
- val = analogRead ( analogPin ); // ocitava analogni ulaz pin
- if(mod == 0){if(1==modUpisa(procitajTaster(val)))mod =1;}
- else modPrezentacije(procitajTaster(val));
- delay(20);
- Serial.println( mod);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement