const int seatPin = D2;
const int beltPin = D3;
const int ignitionPin = D4;
const int speedPin = D5;
const int ledPin = D8;
const int buzzerPin = D9;
void setup() {
pinMode(seatPin, INPUT_PULLUP);
pinMode(beltPin, INPUT_PULLUP);
pinMode(ignitionPin, INPUT_PULLUP);
pinMode(speedPin, INPUT_PULLUP);
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
}
void loop() {
bool seat = digitalRead(seatPin) == LOW;
bool belt = digitalRead(beltPin) == LOW;
bool ignition = digitalRead(ignitionPin) == LOW;
bool speed = digitalRead(speedPin) == LOW;
digitalWrite(ledPin, LOW);
noTone(buzzerPin);
if (seat && ignition) {
if (!belt) {
digitalWrite(ledPin, HIGH);
if (speed) {
tone(buzzerPin, 1000);
}
}
}
delay(20);
}