Code For an Arduino Theremin

const int photoResistorPin = A0; // Analog input pin for the photoresistor
const int buzzerPin = 9; // Digital output pin for the buzzer

void setup() {
  pinMode(photoResistorPin, INPUT);
  pinMode(buzzerPin, OUTPUT);
}

void loop() {
  int lightLevel = analogRead(photoResistorPin); // Read the photoresistor value
  int frequency = map(lightLevel, 0, 1023, 2000, 200); // Map the light level to a frequency range. Darker = higher pitch

  tone(buzzerPin, frequency); // Output the tone on the buzzer pin

  delay(10); // Short delay before the next reading
}