Werden beide freiliegenden Drähte angefasst, leuchtet eine LED.
/*
* Touch Switch with NPN transistors
* A simple touch sensitive curcuit using two NPN transistors (negative-positive-negative)
*/
int ledPin = 13; // choose the pin for the LED
int touchPin = 0; // choose the pin for the touch sensor
int touchVal = 0; // variable for reading the pin
int THRESHOLD = 5; // change this for different sensitivity
void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
}
void loop() {
touchVal = analogRead(touchPin); // read value
if(touchVal < THRESHOLD) {
digitalWrite(ledPin, HIGH); // switch on the LED
}
else {
digitalWrite(ledPin, LOW); // switch off the LED
}
}
