Created
February 23, 2023 08:28
-
-
Save imiconsystem2/638aa224df4a0b2e5f4845cb265551a4 to your computer and use it in GitHub Desktop.
CUSTOM SWITCH Push Button [Pull-Down] ปุ่มกดที่สามารถกำหนดการใช้งานเอง นี้ เชื่อมต่ออยู่กับ GPIO13 หรือ D13 ของคอนโทลเลอร์
This file contains hidden or 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
| const int buttonPin = 13; | |
| const int ralay = 2; | |
| int buttonState = 0; | |
| void setup() { | |
| Serial.begin(9600); | |
| pinMode(ralay, OUTPUT); | |
| pinMode(buttonPin, INPUT); | |
| } | |
| void loop() { | |
| buttonState = digitalRead(buttonPin); | |
| if (buttonState == HIGH) { | |
| digitalWrite(ralay, HIGH); | |
| Serial.println("on"); | |
| } else { | |
| digitalWrite(ralay, LOW); | |
| Serial.println("off"); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment