私は 60 個の LED の LED ストリップ (WS2812B) を持っています。ストリップの先頭にある LED を点灯させて最後まで送信する次のコードがあります。最後に到達すると、「跳ね返って」ストリップを最初に戻します。
私がやろうとしているのは、LED ストリップの両端を LED で点灯させ、その後ろに小さな道を作ることです。これらの LED はストリップを下って反対側の端まで移動し、交差すると交差します。
現在、ライトを一方向に送信してから、他のコードを実行するため、一度に2行のコードを実行する方法を見つけようとしています。どんな助けでもいただければ幸いです
以下はこれまでの私のコードです。
#include "FastLED.h"
// How many leds in your strip?
#define NUM_LEDS 57
// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 4
#define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
int end_led = 55;
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
}
void loop() {
// First slide the led in one direction
for(int i = 0; i < NUM_LEDS; i++) {
// Set the i'th led to
leds[i] = CRGB::Red;
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
leds[i] = CRGB::Black;
// Wait a little bit before we loop around and do it again
delay(30);
}
// Now go in the other direction.
for(int i = NUM_LEDS-1; i >= 0; i--) {
// Set the i'th led to red
leds[i] = CRGB::Red;
// Show the leds
FastLED.show();
// now that we've shown the leds, reset the i'th led to black
leds[i] = CRGB::Black;
// Wait a little bit before we loop around and do it again
delay(30);
}
}