int hallPin = 2;
int redLedPin = 3;
int greenLedPin = 4;
int buzzerPin = 5;
int buttonPin = 6;
int buttonState = 0;
void setup() {
pinMode(hallPin, INPUT);
pinMode(redLedPin, OUTPUT);
pinMode(greenLedPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
int hallValue = digitalRead(hallPin);
buttonState = digitalRead(buttonPin);
if (buttonState == LOW) {
digitalWrite(redLedPin, LOW);
digitalWrite(greenLedPin, HIGH);
noTone(buzzerPin);
} else {
if (hallValue == HIGH) {
digitalWrite(redLedPin, HIGH);
digitalWrite(greenLedPin, LOW);
tone(buzzerPin, 1000);
} else {
digitalWrite(redLedPin, LOW);
digitalWrite(greenLedPin, HIGH);
noTone(buzzerPin);
}
}
}
//consider the green switch is the hall effect sensor
//when u press the green switch the sensor value will be HIGH
//if u want to reset sensor value just press it again
//black switch will mute the buzzer (stay press to mute)