add a second strip to control

bluepill
JbLb 6 years ago
parent e9c112b6eb
commit 9ab9d364eb

@ -6,7 +6,7 @@
#include "leds_config.h" #include "leds_config.h"
// Declare our NeoPixel strip object: // Declare our NeoPixel strip object:
Adafruit_NeoPixel strip(LED_STRIP * NB_STRIP , PIN, NEO_GRB + NEO_KHZ800); Adafruit_NeoPixel strip(LED_STRIP *NB_STRIP, PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels in NeoPixel strip // Argument 1 = Number of pixels in NeoPixel strip
// Argument 2 = Arduino pin number (most are valid) // Argument 2 = Arduino pin number (most are valid)
// Argument 3 = Pixel type flags, add together as needed: // Argument 3 = Pixel type flags, add together as needed:
@ -289,16 +289,18 @@ void loop()
digitalWrite(LED_BUILTIN, (timeNow % 2000) < 1000); digitalWrite(LED_BUILTIN, (timeNow % 2000) < 1000);
Receive(); Receive();
Nunchuk_control(); Nunchuk_control();
strip.clear();
strip.setPixelColor(idx_led, strip.Color(128, 0, 0));
strip.setPixelColor((NB_STRIP * LED_STRIP) - 1 - idx_led, strip.Color(128, 0, 0)); // second LEDs strip
strip.show();
if (iTimeSend > timeNow) if (iTimeSend > timeNow)
return; return;
if (cmd2 == 0) if (cmd2 == 0)
return; return;
iTimeSend = timeNow + ((200 - abs(cmd2)) * 2); // TIME_SEND iTimeSend = timeNow + ((200 - abs(cmd2)) * 2); // TIME_SEND
strip.clear(); if (cmd2 > 0)
strip.setPixelColor(idx_led, strip.Color(128, 0, 0)); {
if (cmd2 > 0){ if (idx_led < LED_STRIP - 1)
if (idx_led < strip.numPixels() -1 )
{ {
idx_led++; idx_led++;
} }
@ -309,14 +311,13 @@ void loop()
} }
else else
{ {
if (idx_led > 0 ) if (idx_led > 0)
{ {
idx_led--; idx_led--;
} }
else else
{ {
idx_led = strip.numPixels() -1 ; idx_led = LED_STRIP - 1;
} }
} }
strip.show();
} }

Loading…
Cancel
Save