Advertisement
Guest User

Untitled

a guest
Jan 10th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.68 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <wiringPi.h>
  3.  
  4.  
  5. #define BTNUP 24
  6. #define BTNDN 25
  7.  
  8. int main(void) {
  9.    
  10.     int fd, num = 20;
  11.    
  12.     wiringPiSetup();
  13.    
  14.     pinMode(BTNUP, INPUT);
  15.     pinMode(BTNDN, INPUT);
  16.  
  17.     fd = lcdInit(2, 16, 4, 5, 4, 0, 1, 2, 3, 4, 5, 6, 7);
  18.    
  19.     lcdPosition(fd, 0, 1);
  20.     lcdPuts(fd, "       xyzString");
  21.    
  22.     while(1) {
  23.         if(digitalRead(BTNDN == 1)) {
  24.             delay(10);
  25.             if (digitalRead(BTNDN) == 1) {
  26.                 num--;
  27.             }
  28.             while(digitalRead(BTNDN));
  29.         }
  30.        
  31.         if(digitalRead(BTNUP) == 1) {
  32.             delay(10);
  33.             if (digitalRead(BTNUP) == 1) {
  34.                 num++;
  35.             }
  36.             while(digitalRead(BTNUP));
  37.         }
  38.        
  39.         lcdPosition(fd, 0, 0);
  40.         lcdPrintf(fd, "%d", num);  
  41.     }  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement