September 17, 2022
Home »
diklatbimtekws
» PELATIHAN INTERNET OF THING (IoT) SEAMOLEC (4 LED DENGAN 1 BUTTON)
PELATIHAN INTERNET OF THING (IoT) SEAMOLEC (4 LED DENGAN 1 BUTTON)
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(2, INPUT);
pinMode(23, OUTPUT);
pinMode(22, OUTPUT);
pinMode(19, OUTPUT);
pinMode(18, OUTPUT);
Serial.println("Hello, ESP32!");
}
int on_off = 0;
void loop() {
// put your main code here, to run repeatedly:
int nilai = digitalRead(2);
//Serial.println(nilai);
if(nilai == 1) {
on_off++;
Serial.println(on_off);
if (on_off == 1) {
digitalWrite(23, HIGH);
digitalWrite(22, HIGH);
digitalWrite(19, HIGH);
digitalWrite(18, HIGH);
}else if (on_off ==2){
digitalWrite(23, LOW);
digitalWrite(22, LOW);
digitalWrite(19, LOW);
digitalWrite(18, LOW);
}
else {
digitalWrite(23, LOW);
digitalWrite(22, LOW);
digitalWrite(19, LOW);
digitalWrite(18, LOW);
on_off = 0;
}
}
//delay(1000); // this speeds up the simulation
}
my name is Dina I'm a teacher at a private high school in Bondowoso Indonesia loves education and likes education development
0 comments:
Post a Comment