Pages: [1]   Go Down
Author Topic: LED Sensor  (Read 1442 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?
Logged

0
Offline Offline
Jr. Member
**
Karma: 0
Posts: 91
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.  smiley
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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");
 }
  
  
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 14
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I got it, heres the code if anyone is intrested
Code:
//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);
 }
  
Logged

Pages: [1]   Go Up
Jump to: