From 25f29d62109f82dbd244873af318ab744e63b503 Mon Sep 17 00:00:00 2001 From: JbLb Date: Sun, 9 Feb 2020 00:05:40 +0100 Subject: [PATCH] led anination proportional to speed --- hoverserial.ino | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/hoverserial.ino b/hoverserial.ino index c2e9a6f..55b7577 100644 --- a/hoverserial.ino +++ b/hoverserial.ino @@ -294,16 +294,31 @@ void loop() if (iTimeSend > timeNow) return; - iTimeSend = timeNow + TIME_SEND; + if (cmd2 == 0) + return; + iTimeSend = timeNow + ((200 - abs(cmd2)) * 2); // TIME_SEND strip.clear(); strip.setPixelColor(idx_led, strip.Color(128, 0, 0)); - if (idx_led < strip.numPixels() -1 ) - { - idx_led++; + if (cmd2 > 0){ + if (idx_led < strip.numPixels() -1 ) + { + idx_led++; + } + else + { + idx_led = 0; + } } else { - idx_led = 0; + if (idx_led > 0 ) + { + idx_led--; + } + else + { + idx_led = strip.numPixels() -1 ; + } } - strip.show(); + strip.show(); }