MENGONTROL KIPAS ANGIN MENGGUNAKAN SENSOR PIR (SENSOR GERAK)
- Jum'at, 22 November 2024
- Elektronika
- Administrator
- 0 komentar
KODING:
const int sensor = 12;
const int kipas = 13;
int sensorState;
void setup() {
Serial.begin(9600);
pinMode(kipas, OUTPUT);
pinMode(sensor, INPUT);
}
void loop() {
sensorState = digitalRead(sensor);
if (sensorState == HIGH) {
Serial.println("kipas nyala");
Serial.println(sensorState);
digitalWrite(kipas, LOW);
delay (2000);
} else {
digitalWrite(kipas, HIGH);
Serial.println("kipas mati");
Serial.println(sensorState);
delay (2000);
}
}
SELAMAT MENCOBA..