Skip to content

Instantly share code, notes, and snippets.

@valbeat
Created August 15, 2015 17:04
Show Gist options
  • Save valbeat/c1f4944878e231805222 to your computer and use it in GitHub Desktop.
Save valbeat/c1f4944878e231805222 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <unistd.h>
#include <wiringPi.h>
#define BUTTON1 2
#define BUTTON2 3
#define BUTTON3 4
int main(void) {
if (wiringPiSetupGpio() == -1) return 1;
pinMode(BUTTON1,INPUT);
pinMode(BUTTON2,INPUT);
pinMode(BUTTON3,INPUT);
while(1) {
if (digitalRead(BUTTON1) == 0) {
printf("%s\n", "BUTTON1");
}
if (digitalRead(BUTTON2) == 0) {
printf("%s\n", "BUTTON2");
}
if (digitalRead(BUTTON3) == 0) {
printf("%s\n", "BUTTON3");
}
delay(100);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment