Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <wiringPi.h>
- #define BTNUP 24
- #define BTNDN 25
- int main(void) {
- int fd, num = 20;
- wiringPiSetup();
- pinMode(BTNUP, INPUT);
- pinMode(BTNDN, INPUT);
- fd = lcdInit(2, 16, 4, 5, 4, 0, 1, 2, 3, 4, 5, 6, 7);
- lcdPosition(fd, 0, 1);
- lcdPuts(fd, " xyzString");
- while(1) {
- if(digitalRead(BTNDN == 1)) {
- delay(10);
- if (digitalRead(BTNDN) == 1) {
- num--;
- }
- while(digitalRead(BTNDN));
- }
- if(digitalRead(BTNUP) == 1) {
- delay(10);
- if (digitalRead(BTNUP) == 1) {
- num++;
- }
- while(digitalRead(BTNUP));
- }
- lcdPosition(fd, 0, 0);
- lcdPrintf(fd, "%d", num);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement