I am trying to replicate Low power LED firefly project. So what I'm trying to do is to do an analog read from a LED, to detect light. To simplify it a bit, I am using different pins and different leds for IN and OUT. The code:
#define PIN1 don't use this pin! /*this is RESET*/
#define PIN2 3
#define PIN3 4
#define PIN4 don't use this pin! /*this is GND*/
#define PIN5 0
#define PIN6 1
#define PIN7 2
#define PIN8 don't use this pin! /*this is VCC*/
#define ANL1 PIN7
#define ANL2 PIN3
#define ANL3 PIN2
// the setup function runs once when you press reset or power the board
void setup() {
digitalWrite(PIN3, LOW);
pinMode(PIN3, INPUT);
}
#define BLINK true
// the loop function runs over and over again forever
void loop() {
const int value = analogRead(PIN3);
if(value>=1023) {
pinMode(PIN2, OUTPUT);
digitalWrite(PIN2, HIGH);
delay(500);
digitalWrite(PIN2, LOW);
delay(3);
}
else {
delay(1);
}
}
This is the setup. I am using much smaller resistor, but I'm still getting 1023 on analog read, as indicated by the output led always being on:
simulate this circuit – Schematic created using CircuitLab
What's wrong?