Skip to content

Instantly share code, notes, and snippets.

@penpencool
Created May 20, 2018 16:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save penpencool/c9a9397a1ce212acfe1d2b6c754643f8 to your computer and use it in GitHub Desktop.
Save penpencool/c9a9397a1ce212acfe1d2b6c754643f8 to your computer and use it in GitHub Desktop.
/* Example By ArduinoAll
*ต่อขา Module -> arduino
1-> Pin 2
2-> Pin 3
3-> Pin 4
4-> Pin 5
Vcc->5V
GND->GND
*/
int buttonPin2 = 2;
int buttonState2 = 0;
int buttonPin3 = 3;
int buttonState3 = 0;
int buttonPin4 = 4;
int buttonState4 = 0;
int buttonPin5 = 5;
int buttonState5 = 0;
void setup() {
Serial.begin(9600);
pinMode(buttonPin2, INPUT);
pinMode(buttonPin3, INPUT);
pinMode(buttonPin4, INPUT);
pinMode(buttonPin5, INPUT);
}
void loop() {
buttonState2 = digitalRead(buttonPin2);
buttonState3 = digitalRead(buttonPin3);
buttonState4 = digitalRead(buttonPin4);
buttonState5 = digitalRead(buttonPin5);
if (buttonState2 == HIGH) {
Serial.println("Touch 1");
}
if (buttonState3 == HIGH) {
Serial.println("Touch 2");
}
if (buttonState4 == HIGH) {
Serial.println("Touch 3");
}
if (buttonState5 == HIGH) {
Serial.println("Touch 4");
}
delay(100);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment