Light level meter using arduino and LDR
This is a simple Light level meter using arduino UNO and LDR.
You can change the sensitivity by change the number that written after "Light /" in programming code.
for making this project you don't need to use light sensor module(only LDR and 10K resistor).
You can change the sensitivity by change the number that written after "Light /" in programming code.
for making this project you don't need to use light sensor module(only LDR and 10K resistor).
int led[10] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
int adjust = 0;
int Light, i;
void setup()
{
for (i=0;i<10; i++)
pinMode(led[i], OUTPUT);
Serial.begin(9600);
}
void loop()
{
Light = analogRead(adjust);
Serial.println(Light);
Light = Light / 50;
Serial.println(Light);
if (Light == 0)
{
for(i = 0; i < 10; i++)
{
digitalWrite(led[i], LOW);
}
}
else
{
for(i = 0; i < Light; i++)
{
digitalWrite(led[i], HIGH);
}
for(i = i; i < 10; i++)
{
digitalWrite(led[i], LOW);
}
}
delay(100);
}
Komentar
Posting Komentar