Hi everyone, so my project is really simple-I have a LDR (photoresistor) and a LED.When the laser hits the LDR the LED is off and vice versa.
I have JS 5080 18 speaker 2" 0.5w 8 ohm and I want it to make sound when the laser is off
here is the code I'm using for the LED
int potPin = 2;
int ledPin = 13;
int val = 0;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop() {
val = analogRead(potPin);
if(val>300){
digitalWrite(ledPin, HIGH);
}else{
digitalWrite(ledPin, LOW);
}}
thanks in advance!