/* Switches, buzzer and LED Circuit Connections: PIN_0 => Resistor 220Ω => Buzzer_Positive - Buzzer_Negative = > Gnd PIN_1 => Resistor 220Ω => LED_Anode - LED_Cathode = > Gnd PIN_8 => Pull down resistor (220Ω) => switch_1 (Vcc) PIN_9 => Pull down resistor (220Ω) => switch_2 (Vcc) */ #define Buzzer_pin 0 //give the name “Buzzer_pin” to PIN_0 #define led_pin 1 //give the name “led_pin” to PIN_1 #define Sw1_pin 8 //give the name “Sw1_pin” to PIN_8 #define Sw2_pin 9 //give the name “Sw2_pin” to PIN_9 //The setup() function initializes and sets the initial values //It will only run once after each powerup or reset void setup() { //Configure PIN_0 and PIN_1 to behave as output //Configure PIN_8 and PIN_9 to behave as input pinMode(Buzzer_pin, OUTPUT); pinMode(led_pin, OUTPUT); pinMode(Sw1_pin, INPUT); pinMode(Sw2_pin, INPUT); } //This function loops consecutively void loop() { //The Buzzer follows the state of switch_1 digitalWrite(Buzzer_pin, digitalRead(Sw1_pin)); //The LED follows the invert state of switch_2 digitalWrite(led_pin, !digitalRead(Sw2_pin)); }