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);
}}
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 1 year ago
@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 :-) )
lampjekenyer 1 year ago
Very useful. is it possible to just use one LED?
jonnycapone1 1 year ago
@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.)
lampjekenyer 1 year ago
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 ;)
rapatski 1 year ago
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 :)
lampjekenyer 1 year ago