Tutorials with Arduino: Led controlled by photo sensor

This has been my first project  Arduino UNO. It´s a very simple project, controlling the intenisty of a light with a photoresistor. As darker it gets, the stronger the light will get, and the brighter it gets, the light goes down. Here is a video of the project working: http://youtu.be/pCRhzh3d6ww Part List:

  • 1 x  Arduino UNO
  • 1 x photosensor
  • 1 x 10k resist
  • 1 x 220 ohm resist
  • 1 x breadboard

arduino + photosensor     The source code is based on this tutorial:: www.ladyada.net/learn/sensors/cds.html with a few tweaks. /* Photocell Led. * ————– * * @author: Javier Lander * @hardware: Javier Lander * www.mrlndr.com * twitter: @mrlndr */ int photocellPin = 3; // the cell and 10K pulldown are connected to a0 int photocellReading; // the analog reading from the sensor divider int LEDpin = 11; // connect Red LED to pin 11 (PWM pin) int LEDbrightness; // void setup(void) { // We’ll send debugging information via the Serial monitor Serial.begin(9600); } void loop(void) { photocellReading = analogRead(photocellPin); Serial.print(«Analog reading = «); Serial.println(photocellReading); // the raw analog reading // LED gets brighter the darker it is at the sensor // that means we have to -invert- the reading from 0-1023 back to 1023-0 photocellReading = 1023 – (photocellReading); //now we have to map 0-1023 to 0-255 since thats the range analogWrite uses LEDbrightness = map(photocellReading, 0, 1023, 0, 255); analogWrite(LEDpin, LEDbrightness); Serial.print(«Led = «); Serial.println(LEDbrightness); // the raw analog reading delay(10); }

Related Posts

  • Tutorials with Arduino: Digital thermometer #arduino #displayFinally we are doing something else than our SM-1 Ikea Robot Lamp. It´s been refreshing doing some other projects and tutorials, because these last days have been everything about the robot. See it in action on this video (and watch out for the fire part!) http://www.youtube.com/watch?v=sbP1CUqC5EA So, let´s get to…
    Tags: the, to, a, tutorial, led, arduino
  • Tutorials with Arduino: Arduino controlled by Apple Remote (updated)Controlling Leds by the Apple Remote (video updated using the Iphone Photostudio for Arduino Stand) http://www.youtube.com/watch?v=vjnOvdJrHMo The idea originated because i´m learning a lot on Led driven home applications for lighting, and the first project i´m doing is led lighting for the kitchen (indirect). The commercial systems are very expensive,…
    Tags: the, led, tutorial, dimmer, arduino
  • On #Kickstarter: 13 #arduino projects that will blow your mind!While i was searching on the internet a list on Arduino based projects on Kickstarter, i couldn´t find a good list... so i made one! at least the projects i really like. If you feel there is a project missing, or would like your project to be promoted on the…
    Tags: the, to, a, arduino

2 comentarios

  1. I would like to have an Arduino to program it for controlling a solar panel system for powering a whole home, by driving 2 axis sun tracking of the solar cells and monitoring voltages and currents to the loads or battery chargers/inverters. I would be very pleased if i win one of these Arduinos Uno R3.