LED as lightsensor on the arduino

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
3,753
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Mar 26, 2010

still playing with the arduino. I noticed that the cheap light-sensors are not available anymore because of cadmium?! I read somewhere that a LED can also be used reverse as a light sensor. That seems like a good arduino project. It took me some time to figure it out, because the readings are not very reliable. But when I take the average of several readings, it seems to work :)

Here comes the code:
Where I wrote ### (4x) you should put the "smaller than" symbol. (that symbol is not allowed in YouTube)

int led = 13;
int basis = 0;
int sens = 0;
int x = 0;
int y = 0;
int totaal = 0;
int totaal1 = 0;
void setup() {
pinMode(led, OUTPUT);}
void loop() { for(x =0; x ### 50; x++){ sens = analogRead(0); totaal = totaal1 + sens; totaal1 = totaal;}
sens = totaal/x;
totaal = 0;
totaal1 = 0; basis = sens-20;
for(y=0;y###1000;y++){ for(x =0; x ### 50; x++){ sens = analogRead(0); totaal = totaal1 + sens; totaal1 = totaal; delay(10); } sens = totaal/x; if (sens###basis) digitalWrite(led, HIGH); else digitalWrite(led, LOW); totaal = 0; totaal1 = 0; delay(10);
}}

Category:

Science & Technology

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (lampjekenyer)

  • Try using a red, green, and blue led. Even better, use the analog input values from said leds to control analog output on an rgb led.

  • @GTechno13 Thanx for your reply. I tried different colors already. (see my other clips) some work better than others. I'm working on something nice to control with it. The LED will be sensor one moment and LED the other. I hope to finish (and post) it soon. (I just have to find the time :-) )

  • Very useful. is it possible to just use one LED?

  • @jonnycapone1 Yes! just the green LED is the sensor. The other LED is just there to react on it. In the near future I want to make a whole array of LEDs to react on just one LED that will act as the sensor. (not all colors have the same effect. Just experiment with that.)

  • mooi zeg.. ik he ook zo'n arduinootje, maar ik heb echt een belabberde basis voor electronica. ik snap nauwelijks wat een weerstandje doet. kun jij dat niet een keertje uitleggen tijdens een deltaevenementje oid? :)

    programmeren lukt me dan weer wél aardig ;)

  • Leuk dat jij ook een arduino hebt. Ik had nog niemand gevonden die 'm ook had. Ik heb ook helemaal niet zoveel verstand van elektronica, maar de combinatie arduino en youtube, zorgt ervoor dat ik heel snel leer. Volgende keer dat we gaan vliegen moeten we dan maar de arduino en een doos elektronica onderdelen meenemen. Is weer een leuk tijdverdrijf tussen de vluchten door :)

see all

All Comments (7)

Sign In or Sign Up now to post a comment!
  • this is fuckin STUPID!

Loading...

Alert icon
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more