dhenry:
Not sure what your code is trying do but this is what I would try:If you build it you will see an LED recognises the flash of another LED by flashing itself in the same sequence . So if I press the button on LED1 ,on and off the LED2 flashes on and off
//put some delays here
NOP(); NOP(); NOP(); NOP(); NOP();This does not compile. When I add in what is required to compile it with a delay(400) I get alternating flashing LED's . So that's a bit vague , What are you trying to do and maybe I can help you
led_adc() energies the led capacitance and then adc the charge transfer. For high led capacitance, you should read a voltage very close to 1023; Lower led capacitance results in lower reading - more charges are transfered to Chold -> lower voltage across the led capacitor.
//read reverse of a led's cathode
#define NOP() asm("nop") //waste a tick
void setup(){
Serial.begin(9600);}
unsigned short led_adc(unsigned char pin) {
//energize the pin
digitalWrite(pin, HIGH);
pinMode(pin, OUTPUT);
//put some delays here
NOP(); NOP(); NOP(); NOP(); NOP();
delay(400);
//adc the pin
pinMode(pin, INPUT);
return analogRead(pin);
}
void loop(){
//read A1
Serial.print("Value 1 : ");
Serial.println(led_adc(A1));
//out(led1,led2,threshold1);
//pinMode(led2,INPUT);
//read A2
Serial.print("Value 2 : ");
Serial.println(led_adc(A2));
}