Created
May 20, 2018 16:14
-
-
Save penpencool/c9a9397a1ce212acfe1d2b6c754643f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* 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