Light Sensitive

This allows you to toggle the use of the LED’s by using the button and you can turn the knob to change the frequency and the number of lights that are on

Step 1

Step 1

int LDRPin = A4;
int buzzerPin = 3;
int LDRvalue = 0;
int freq = 0;

void setup()
{
Serial.begin(115200);
}

void loop()
 {
 LDRvalue = analogRead(LDRPin);
 LDRvalue = map(LDRvalue, 0, 1023, 0, 500);
 freq = map(LDRvalue, 0, 1023, 200, 800);
 Serial.println(LDRvalue);
 Serial.println(freq);
 tone(buzzerPin, freq, LDRvalue);
 delay(1000);
 }

Add a comment