From b40b413c3d04a985af14750887c38e32fbac5fd6 Mon Sep 17 00:00:00 2001 From: Stefan Heinrichsen Date: Sat, 13 Apr 2019 15:19:17 +0200 Subject: [PATCH] Fixed memory leak, minor cleanups --- FastTouch.ino | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/FastTouch.ino b/FastTouch.ino index 6f89c2f..1c46333 100644 --- a/FastTouch.ino +++ b/FastTouch.ino @@ -4,14 +4,14 @@ #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); +NeoPixelBus strip(NUMPIXELS, WS_PIN); int touch_value = 100; int i = 0; int d = 1; -RgbColor black(0); -RgbColor white(255); +RgbwColor black(0); +RgbwColor white(255); void setup() { Serial.begin(115200); @@ -27,17 +27,18 @@ void setup() { void loop(){ touch_value = touchRead(TOUCH_PIN); - if (touch_value < 50) { - Serial.print("Touch @ "); + if ( (touch_value>10) && (touch_value < 50)) { + //Serial.print("Touch @ "); + Serial.print("@"); i+=d; } - Serial.println(touch_value); + //Serial.println(touch_value); + //Serial.println(i); strip.ClearTo(black); strip.SetPixelColor(i, white); strip.Show(); - if(i==NUMPIXELS || i == 0) { d=d*(-1); } - - + if(i>=NUMPIXELS ) { d=(-1); } + if(i<=0 ) { d=1; } delay(10); }