int button1=18; //3;
int button2=22; //4;
int button3=21; //5;
int button4=19; //6;
int NUM_A,NUM_B;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32-S2!");
pinMode(button1,INPUT);
pinMode(button2,INPUT);
pinMode(button3,INPUT);
pinMode(button4,INPUT);
NUM_A=0,NUM_B=0;
}
void loop() {
if(digitalRead(button1)==LOW&&NUM_A>=0&&NUM_A<99)
{while(digitalRead(button1)==LOW)
delay(100);
NUM_A++;
}
else if(digitalRead(button2)==LOW&&NUM_A>0&&NUM_A<=99)
{while(digitalRead(button2)==LOW)
delay(100);
NUM_A--;
}
if(digitalRead(button3)==LOW&&NUM_B>=0&&NUM_B<99)
{while(digitalRead(button3)==LOW)
delay(100);
NUM_B++;
}
else if(digitalRead(button4)==LOW&&NUM_B>0&&NUM_B<=99)
{while(digitalRead(button4)==LOW)
delay(100);
NUM_B--;
}
delay(10);
// put your main code here, to run repeatedly:
delay(10); // this speeds up the simulation
Serial.print("NUM_A=");
Serial.print(NUM_A);
Serial.print(", NUM_B=");
Serial.println(NUM_B);
}
esp:0
esp:1
esp:2
esp:3
esp:4
esp:5
esp:6
esp:7
esp:8
esp:9
esp:10
esp:11
esp:12
esp:13
esp:14
esp:15
esp:16
esp:17
esp:18
esp:19
esp:20
esp:21
esp:26
esp:33
esp:34
esp:35
esp:36
esp:37
esp:38
esp:39
esp:40
esp:41
esp:42
esp:45
esp:46
esp:3V3
esp:5V
esp:GND.1
esp:TX
esp:RX
esp:RST
esp:GND.2
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
btn2:1.l
btn2:2.l
btn2:1.r
btn2:2.r
btn3:1.l
btn3:2.l
btn3:1.r
btn3:2.r
btn4:1.l
btn4:2.l
btn4:1.r
btn4:2.r
r1:1
r1:2
r2:1
r2:2
r3:1
r3:2
r4:1
r4:2