Skip to content

Instantly share code, notes, and snippets.

@silasb
Created September 27, 2010 03:55
Show Gist options
  • Save silasb/598580 to your computer and use it in GitHub Desktop.
Save silasb/598580 to your computer and use it in GitHub Desktop.
//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()
{
//REVERSE BIAS
digitalWrite(cath, HIGH);
digitalWrite(ando, LOW);
//CHARGE LED
delay(6);
//READ LED CAP
pinMode(ando, INPUT);
delay(6);
//WRITE TO LED
if (digitalRead(ando) == LOW)
{
digitalWrite(led1,HIGH);
Serial.print("ON");
}
else
{
digitalWrite(led1,LOW);
Serial.print("OFF");
}
//RESET
pinMode(ando, OUTPUT);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment