/*
Input : Switch
Output : Buzzer
Project : Play tone on Buzzer
Edited : 6th Jan 2026 by Zarina MN
*/
//#include "pitches.h"
#define SWITCH_PIN 7
#define SPEAKER_PIN 8
void setup() {
pinMode(SWITCH_PIN, INPUT);
pinMode(SPEAKER_PIN, OUTPUT);
}
void loop() {
if (digitalRead(SWITCH_PIN) == LOW){
tone(SPEAKER_PIN, 262);
} else {
noTone(SPEAKER_PIN);
}
}ON <--> OFF (active-LOW)