-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTable_lamp
More file actions
30 lines (29 loc) · 747 Bytes
/
Table_lamp
File metadata and controls
30 lines (29 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# define PIN_LED 2
# define PIN_BUTTON 13
//the setup functions runs once when you press reset or power on the esp32 board
void setup() {
//initialize digital PIN_LED as an output
pin Mode (PIN_LED,OUTPUT);
pin Mode (PIN_BUTTON,INPUT);
}
//the loop functions runs over and over again forever
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead (PIN_BUTTON)==LOW) {
delay(20);
if(digitalRead (PIN_BUTTON)==LOW) {
reverseGPIO(PIN_LED);
}
while (digitalRead(PIN_BUTTON)==LOW);
delay(20);
if(digitalRead(PIN_BUTTON)==LOW){
reverseGPIO(PIN_LED);
}
while (digitalRead(PIN_BUTTON)==LOW);
delay(20);
if(digitalRead(PIN_BUTTON)==LOW)
}
}
void reverseGPIO(int pin) {
digitalWrite (pin, !digitalRead(pin));
}