1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
HardwareSerial &pc = Serial; #define pBTN 4 #define pLED 13 void setup() { pinMode(pBTN, INPUT_PULLUP); pc.begin(9600); } void loop() { if( digitalRead(pBTN) ) { while(digitalRead(pBTN)); delay(300); digitalWrite(pLED, !digitalRead(pLED)); pc.println(digitalRead(pLED) ? "ON" : "OFF"); } } |