Go Down

Topic: LED Sensor (Read 1 time) previous topic - next topic

ricky2443

I read on the tutorials page about using and LED as a light sensors, it sounds great but its in french. I was wondering if there was anybody who has attempted this in english?

brainfart

http://www.merl.com/reports/docs/TR2003-35.pdf has instructions for doing this with microcontrollers.

http://www.instructables.com/id/E6PN27M4CPEP286H58/ uses LEDs as light sensors too. I like that one a lot.  :)

ricky2443

Ok so i read the article and im trying to get this work but so far i can only get the sensor led to turn on and off im not sure how to get it to turn off and led when its dark around it.
Code: [Select]
int led1 = 13;
int cath = 2; // negative
int ando = 3;  // positive

void setup()
{
  pinMode(led1, OUTPUT);
  pinMode(cath, OUTPUT);
  pinMode(ando, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  //TURN SENSOR LED ON
  digitalWrite(cath, LOW);
  digitalWrite(ando, HIGH);
  delay(10);
//REVERSE BIAS
  digitalWrite(cath, HIGH);
  digitalWrite(ando, LOW);
  //READ LED CAP
  pinMode(ando, INPUT);
  //WRITE TO LED
  digitalWrite(led1,digitalRead(ando));
  //RESET
  pinMode(ando, OUTPUT);
  Serial.print("Reset");
}
 
 

ricky2443

I got it, heres the code if anyone is intrested
Code: [Select]
//TOUCH SENSING BETA - LED TURNS ON WHEN LIGHT IS PRESENT
//BY: RICARDO DE LEMOS 1/17/2007
int led1 = 13;
int cath = 2; // negative
int ando = 3;  // positive

void setup()
{
  pinMode(led1, OUTPUT);
  pinMode(cath, OUTPUT);
  pinMode(ando, OUTPUT);
  Serial.begin(9600);
}

void loop()
{
  //TURN SENSOR LED ON
  digitalWrite(cath, LOW);
  digitalWrite(ando, HIGH);
  delay(80);
  //REVERSE BIAS
  digitalWrite(cath, HIGH);
  digitalWrite(ando, LOW);
  //CHARGE LED
  delay(80);
  //READ LED CAP
  pinMode(ando, INPUT);
  delay(80);
  //WRITE TO LED
  if (digitalRead(ando) == LOW)
  {
    digitalWrite(led1,LOW);
  }
  else
  {
    digitalWrite(led1,HIGH);
  }
  //RESET
  pinMode(ando, OUTPUT);
}
 

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy