#include "pitches.h"
#define SPEAKER_PIN 3
#define LDR_THRESHOLD 500 // Adjust based on lighting conditions
const uint8_t ldrPins[] = {A0, A1, A2, A3, A4, A5}; // LDR analog pins
const int ldrTones[] = {
NOTE_C2, NOTE_D2, NOTE_E2, NOTE_F2,
NOTE_G2, NOTE_A2
};
const int numTones = sizeof(ldrPins) / sizeof(ldrPins[0]);
void setup() {
pinMode(SPEAKER_PIN, OUTPUT);
}
void loop() {
int pitch = 0;
for (uint8_t i = 0; i < numTones; i++) {
int ldrValue = analogRead(ldrPins[i]); // Read LDR value
if (ldrValue < LDR_THRESHOLD) { // Hand blocks light → Play note
pitch = ldrTones[i];
}
}
if (pitch) {
tone(SPEAKER_PIN, pitch);
} else {
noTone(SPEAKER_PIN);
}
}