Last active
October 18, 2022 10:02
-
-
Save truongtpa/5741d494691b676f5d26189993fdc61d to your computer and use it in GitHub Desktop.
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
| void setup() { | |
| Serial.begin(9600); | |
| Serial.println("Xin chao....."); | |
| pinMode(13, OUTPUT); | |
| pinMode(3, INPUT); | |
| } | |
| int st_nut = LOW; // Trạng thái trước đó của nút | |
| long time_A = 0; // TG nhấn nút A | |
| void loop() { | |
| int st = digitalRead(3); | |
| // A | |
| if(st_nut == LOW && st == HIGH){ | |
| time_A = millis(); | |
| } | |
| // B | |
| if(st_nut == HIGH && st == LOW){ | |
| Serial.println(millis() - time_A); | |
| if(millis() - time_A > 500){ | |
| digitalWrite(13, HIGH); | |
| delay(5000); | |
| } | |
| } | |
| digitalWrite(13, LOW); | |
| st_nut = st; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment