BREAKING NEWS

06 November 2015

Arduino Light Sensor

Today we introduce a new component: the solar resistance. It changes the amount of electric energy that retains and disperses according to the exposure to light.
It 'very practical, economical, small and compact, this makes it ideal for any use made of it has to do, from robots to lights in the closets.

INGREDIENTS:
  • 1 led
  • Resistance solar (photo resistor)
  • 3 resistors 1K5Ω
  • a resistance of 100Ω
  • Support (breadboard / matrix board)
PERFORMANCE:
CODE:
int ledPin = 6;
ldrPin int = 0;
lightVal int = 0;
void setup () {
pinMode (ledPin, OUTPUT);
}
void loop () {
lightVal = analogRead (ldrPin);
digitalWrite (ledPin, HIGH);
delay (lightVal);
digitalWrite (ledPin, LOW);
delay (lightVal);
}

Share this:

Post a Comment

 
Back To Top
Distributed By Blogger Templates | Designed By OddThemes