SDL2 audio record test
[mirrors/Programs.git] / arduino / led_touch / led_touch.pde
1 //TOUCH SENSING BETA - LED TURNS ON WHEN LIGHT IS PRESENT
2 //BY: RICARDO DE LEMOS 1/17/2007
3 int led1 = 13;
4 int cath = 2; // negative
5 int ando = 3; // positive
6
7 void setup()
8 {
9 pinMode(led1, OUTPUT);
10 pinMode(cath, OUTPUT);
11 pinMode(ando, OUTPUT);
12 //Serial.begin(9600);
13 }
14
15 int dela = 20;
16 int last = HIGH;
17 int shine = HIGH;
18
19 void loop()
20 {
21 //TURN SENSOR LED ON
22 pinMode(ando, OUTPUT);
23 if(shine) {
24 digitalWrite(cath, LOW);
25 digitalWrite(ando, HIGH);
26 delay(100);
27 }
28
29 //REVERSE BIAS + CHARGE LED
30 digitalWrite(cath, HIGH);
31 digitalWrite(ando, LOW);
32 //delay(dela);
33
34 //READ LED CAP
35 pinMode(ando, INPUT);
36 delay(dela);
37 int state = digitalRead(ando);
38
39 //SWITCH
40 if((state != last) && state == LOW) shine = !shine;
41 last = state;
42
43 //DEBUG LED
44 if(state) {
45 digitalWrite(led1,HIGH);
46 } else {
47 digitalWrite(led1,LOW);
48 }
49 }
50
51
This page took 0.250295 seconds and 4 git commands to generate.