#include <Arduino.h>
const int ledPin = 11; // LED connected to digital pin 11
const int buzzerPin = 10; // Buzzer connected to digital pin 10
const int potPin = A1; // Potentiometer connected to analog pin A1
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buzzerPin, OUTPUT);
pinMode(potPin, INPUT);
}
void loop() {
int potValue = analogRead(potPin); // Read the potentiometer value
if (potValue > 512) { // If the potentiometer value is in the upper half
digitalWrite(ledPin, HIGH); // Turn on the LED
tone(buzzerPin, 261); // Play 261 Hz tone (Middle C)
} else {
digitalWrite(ledPin, LOW); // Turn off the LED
tone(buzzerPin, 330); // Play 330 Hz tone (E4)
}
delay(100); // Short delay between reads
}