From 86a739a0a436a1148a210e66caa5d5937d52fdef Mon Sep 17 00:00:00 2001 From: Stefan Heinrichsen Date: Sat, 13 Apr 2019 10:34:36 +0200 Subject: [PATCH] Added white pixel which moves during touch --- FastTouch.ino | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) mode change 100755 => 100644 FastTouch.ino diff --git a/FastTouch.ino b/FastTouch.ino old mode 100755 new mode 100644 index ab144d9..6f89c2f --- a/FastTouch.ino +++ b/FastTouch.ino @@ -1,18 +1,43 @@ -#define TOUCH_PIN 4 //Für Touch: 2, 4, 12, 13, 14, 15, 27 +#include + +#define WS_PIN 2 // On Trinket or Gemma, suggest changing this to 1 +#define NUMPIXELS 113 // Popular NeoPixel ring size +#define TOUCH_PIN 4 //Für Touch: 2, 4, 12, 13, 14, 15, 27 + +NeoPixelBus strip(NUMPIXELS, WS_PIN); int touch_value = 100; +int i = 0; +int d = 1; -void setup(){ +RgbColor black(0); +RgbColor white(255); + +void setup() { Serial.begin(115200); Serial.println("Touch Test"); + + Serial.println("Switching off all LEDs"); + strip.Begin(); + //strip.SetBrightness(128); + strip.ClearTo(black); + strip.Show(); } void loop(){ touch_value = touchRead(TOUCH_PIN); - - if (touch_value < 65) { Serial.print("Touch @ "); } - Serial.println(touch_value); - delay(20); + if (touch_value < 50) { + Serial.print("Touch @ "); + i+=d; + } + Serial.println(touch_value); + strip.ClearTo(black); + strip.SetPixelColor(i, white); + strip.Show(); + + if(i==NUMPIXELS || i == 0) { d=d*(-1); } + + + delay(10); } -