Welcome, Guest. Please Login or Register
YaBB - Yet another Bulletin Board
09.02.2010 at 17:15:15
News: Server upgrade went fine, you are now at the new system


Pages: 1
LED Sensor (Read 2361 times)
ricky2443
YaBB Newbies
*
Offline



Posts: 14

LED Sensor
17.01.2007 at 03:40:13
 
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?
Back to top
 
 
View Profile   IP Logged
brainfart
Junior Member
**
Offline



Posts: 91

Re: LED Sensor
Reply #1 - 17.01.2007 at 18:40:12
 
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
Back to top
 
 
View Profile   IP Logged
ricky2443
YaBB Newbies
*
Offline



Posts: 14

Re: LED Sensor
Reply #2 - 18.01.2007 at 00:09:46
 
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");
 }

   

Back to top
 
 
View Profile   IP Logged
ricky2443
YaBB Newbies
*
Offline



Posts: 14

Re: LED Sensor
Reply #3 - 18.01.2007 at 04:28:40
 
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);
 }

 

Back to top
 
 
View Profile   IP Logged
Pages: 1