Mechatronics LAB
Published © Apache-2.0

Arduino Workshop-Light Sensor

In this project, we will use an LDR to detect light and a piezo sounder to give audible feedback of the amount of the light detected,

BeginnerFull instructions provided1 hour5,633
Arduino Workshop-Light Sensor

Things used in this project

Story

Read more

Schematics

Arduino Workshop-Light Sensor

Code

Code snippet #1

Arduino
int piezoPin = 8; // Piezo on Pin 8
int ldrPin = 0; // LDR on Analog Pin 0
int ldrValue = 0; // Value read from the LDR
void setup() {
// nothing to do here
}
void loop() {
ldrValue = analogRead(ldrPin); // read the value from the
LDR
tone(piezoPin,1000); // play a 1000Hz tone from the piezo
delay(25); // wait a bit
noTone(piezoPin); // stop the tone
delay(ldrValue); // wait the amount of milliseconds in
ldrValue
}

Credits

Mechatronics LAB

Mechatronics LAB

66 projects • 44 followers
I am Sarful , I am a Mechatronics Engineer & also a teacher I am Interested in the evolution of technology in the automation industry .

Comments