From 2530d2a39b59d5116732d2a2d8e6798d90e99b91 Mon Sep 17 00:00:00 2001 From: Tilman Date: Wed, 29 Apr 2020 15:41:56 +0200 Subject: [PATCH] Gabellichtschranke TCST 2103 --- .../Lichtschranke_TCST2103.ino | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 nano/Lichtschranke_TCST2103/Lichtschranke_TCST2103.ino diff --git a/nano/Lichtschranke_TCST2103/Lichtschranke_TCST2103.ino b/nano/Lichtschranke_TCST2103/Lichtschranke_TCST2103.ino new file mode 100644 index 0000000..bdde16f --- /dev/null +++ b/nano/Lichtschranke_TCST2103/Lichtschranke_TCST2103.ino @@ -0,0 +1,39 @@ +// https://www.youtube.com/watch?v=po_lHVKFQWI +// http://heliosoph.mit-links.info/photointerrupter-basics/ + +/* ++5V --220 Ohm-- ---- GND + | | + + D + TCST2103 + E + + | | + GND ---- ----10kOhm---- +5V + | + | + ----A0 PIN +*/ + + +int sensorPin = A0; +int sensorValue = 0; +int ledPin = LED_BUILTIN; + +void setup() { + pinMode(ledPin, OUTPUT); + Serial.begin(9600); +} + +void loop() { + sensorValue = analogRead(sensorPin); + Serial.println(sensorValue); + + if (sensorValue > 512) { + digitalWrite(ledPin, HIGH); + } + else { + digitalWrite(ledPin, LOW); + } + + delay(200); +}