int LEDred = 32; //declare the pin
int LEDblue = 33; //declare the pin
int PB=4;//push button
int Buzzer = 18;
int NCT_sensor=26;
int PB_value=0;
int NCT_sensor_value=0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(LEDred,OUTPUT);
pinMode(LEDblue,OUTPUT);
pinMode(PB,INPUT);
pinMode(Buzzer,OUTPUT);
pinMode(NCT_sensor,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
PB_value=digitalRead(PB);
NCT_sensor_value=analogRead(NCT_sensor);
Serial.println(NCT_sensor_value);
if(PB_value==1)
{
digitalWrite(LEDred,HIGH);
delay(500); // this speeds up the simulation
digitalWrite(LEDblue,HIGH);
delay(500); // this speeds up the simulation
}
else
{
digitalWrite(LEDred,LOW);
delay(500); // this speeds up the simulation
digitalWrite(LEDblue,LOW);
delay(500); // this speeds up the simulation
}
if(NCT_sensor_value>1534)
{
tone(Buzzer,5000);
}
else
{
noTone(Buzzer);
}
}