Everybody knows that LEDs emit light when you apply voltage on them and current flows through them.
Not everybody knows that LEDs do the reversal too, when the LED is irradiated with light they generate voltage.The more bright is the LED the more voltage it generates.
I made small setup to prove this. First you need high-brigthness LED – I got 8000 mCd red LED and connect the cathode to GND and anode to PIN(1) of DuinoMite as on the picture above.
Then wrote this small code:
10 SETPIN 1,1 ‘setup PIN(1) as analog input
20 A = 0 ‘accumulator variable
30 FOR I = 1 TO 5000 ‘do 5000 times
40 A = A + PIN(1) ‘add the PIN(1) readings to Accumulator i.e. I amplify 5000 times the PIN(1) readings this way
50 NEXT I
60 PRINT A ‘print the result
70 GOTO 20
The 5000 loop is also good to not scroll so fast the print results 🙂
With not irradiated LED the readings are:
If I point it to the red power LED on DuinoMite it reads:
If I point to the yellow LED on Duinomite it reads:
The RED and YELLOW LEDs are with same brightness, then why the readings are different?
The “sensor” LED is most sensitive to the light spectrum it emmits, so when irradiated with RED light it generate more voltage than when irradiated with YELLOW light.
Tomorrow using this feature I will tell you how to teach DuinoMite to recognize colors, using RED, GREEN, BLUE and WHITE LEDs I will build Color-meter and when irradiate the “sensors” with different color light DuinoMite will recognize it and print on the screen.
Now let’s go back to RED only leds and think what else we can do with them. What If I make row of LEDs and scan them sequentially? I will make some low resolution (5 mm dot) scanner.
I make next setup with 4 LEDs wired as “sensors”:
The code nave to be changed to scan for 4 analog inputs:
10 NBR = 100 ‘how much to amplify
20 OPTION BASE 1 ‘option base for the arrays
30 DIM P(4)
40 FOR I = 1 TO 4: SETPIN I,1: NEXT ‘make PIN1-4 as analog inputs
60 FOR I = 1 TO 4: P(I) = 0: NEXT ‘clear the accumulators
70 FOR I = 1 TO NBR ‘read the analog inputs NBR times and add to the accumulators
80 FOR J = 1 TO 4
90 P(J) = P(J) + PIN(J)
100 NEXT J
110 NEXT I
120 FOR I = 1 TO 4 ‘display as graphics bars on the Duinomite VGA screen
130 LINE (I*30,MM.VRES)-(I*30+25,MM.VRES-2*P(I)),1,BF
140 NEXT I
145 PAUSE 200 ‘wait and do it again
150 GOTO 50
When run I can see bar graph which change with the amount of light which fall on the LEDs.
You can see on this video I apply light on the LEDs with RED high intenity LED of same kind, and this generates a lot of response on the “sensor” LEDs.
The same principle is used in this video, it uses 8×8 LED matrix as multi touch touchscreen device, too bad I have no 8 Analog inputs on DuinoMite as if I had I would duplicate this project 🙂
You could even make on the same principle Interractive LED table like THIS