The result could be used in some sort of half-duplex Morse code application or even as an relay or isolator. As tested, the LED does conduct voltage when it senses light of same or lower wavelength than it was designed for. However, the different brands or structures of LEDs differs its capabilities. I provided the source code for Arduino for reference.
/*Demonstrates using LED as a sensor and emitter.
When LED A1 or A2 senses input, the other will emit
light according to the blinking sequence detected*/
#include "pitches.h"
const int led1 = A0;
const int led2 = A1;
const int breakTime = 3000; //in ms
const int speaker = 8;
int value1, value2;
int threshold1 = 250;
int threshold2 = 250;
int numNotes = 4;
boolean timeout = false;
long time = 0;
int melody[] = {
NOTE_A4,NOTE_E4,NOTE_G4,NOTE_A4};
int noteDurations[] = {
4, 4, 4, 4};
void setup(){
Serial.begin(9600);
pinMode(led1,INPUT);
pinMode(led2,INPUT);
pinMode(speaker,OUTPUT);
}
void loop(){
value1 = analogRead(A0);
value2 = analogRead(A1);
if(value1 >= threshold1){
Serial.print("Value 1 : ");
Serial.println(value1);
time = millis();
out(led1,led2,threshold1);
pinMode(led2,INPUT);
timeout = false;
}
else if(value2 >= threshold2){
Serial.print("Value 2 : ");
Serial.println(value2);
time = millis();
out(led2,led1,threshold2);
pinMode(led1,INPUT);
timeout = false;
}
}
void out(int a, int b, int threshold){
pinMode(b,OUTPUT);
delay(20);
while(timeout != true){
int value = analogRead(a);
if(value >= threshold){
analogWrite(b,value);
time = millis();
}
else{
analogWrite(b,0);
}
if(millis() - time >= breakTime){
timeout = true;
playTone();
}
}
}
void playTone(){
for (int thisNote = 0; thisNote < numNotes; thisNote++) {
int noteDuration = 1000/noteDurations[thisNote];
tone(8, melody[thisNote],noteDuration);
int pauseBetweenNotes = noteDuration * 1.30;
delay(pauseBetweenNotes);
noTone(8);
}
}
___________________________________________________________________
This suggest that the red LED has capacitive properties but may differ due to the holding and discharge time of different LED. When the white LED transmits, its very clear that with every quick interval signals, the white light was able to transmit accordingly and with minimum delay.
In terms of sensitivity, the red LED would win hands down. White light consists of broad spectrum rays and the wavelength is undetectable by the red LED unless it is put very VERY closely. With the red LED, the distance between the transmitter and receiver for successful sensing could be larger. However, we must put into account that the noise received from the atmosphere was no doubt a big disadvantage as the experiment was done under fluorescent lighting. This problem was partially solved by calibrating possible received values before writing the threshold values of both sensors. Its very simple. The piezo speaker functions to show end of transmission and the Arduino will start sensing both inputs again.
The testing code used is shown below:
void setup(){
Serial.begin(9600);
pinMode(A0,INPUT);
pinMode(A1,INPUT);
}
void loop(){
int value1 = analogRead(A0);
int value2 = analogRead(A1);
Serial.print("Value 1 = ");
Serial.print(value1);
Serial.print("\tValue 2 = ");
Serial.println(value2);
delay(300);
}
Also include the pitches.h file obtained from the Arduino page .
The circuit drawings were done on Fritzing . It is open-source like the Arduino.




































Can this be done with one LED that is both a dark sensor and a nightlight?
1/100 of a sec, check light level
99/100 of a sec, burn brightly if the area is dark
If you are, then my answer would be yes theoretically, but i have not tested this idea~
However, it also depends on the type of LED you're using (size, color) and etc.
Perhaps there could even be a way to constantly read the (back voltage?) coming from the light hitting the LED. It might involve closely monitoring the actual voltage (current?) sent to the LED and the amount that passes through it (resistance?) could indicate the ambient light level sensed by the LED.
Hope my terminology is close enough for some experts to diagnose my syntax. :)
Relays used could depend on the activation voltage, ranging from lowest 5 volt.
BTW, I greatly appreciate this conversation and I thank you for your time! :)
Well, about your theory of the back EMF; i am sure that it exists for any circuit with a load (power source). However, i am not sure if it alone contributes to the varied voltage measurements. Personally, i would say yes if you were using two different types of batteries (such as energizer vs tesco batteries) for different measurements. But i don't think that was the case, was it? I believe the LED as an input, in turns, generates minor current when subjected to sunlight or anything bright.
When i conducted my LED project with normal office lighting, the output readings from the LED varied below the threshold level i set, which was at 4.88volts, when a light source shown directly on it, it showed readings of over (250/256)x5 = 4.88 volts. This shows that the problem was with the LED and you were right with the back EMF theory here. When the LED becomes a current source, it contributes and affects the readings on the voltmeter especially when the voltmeter is not a properly designed one. To learn to design a voltmeter, you can go search for the topic 'Instrumentation' in engineering. I used the book by H.S. Kalsi :) I hope this helps.