Go Down

Topic: WS2812B Speed Issues (Read 198 times) previous topic - next topic


I am making a project where you input a time and a block of 10 LEDs "move" across the strip in that inputted time. The LEDs do in fact move but they do not change in speed. This is my code:

Code: [Select]

period = (INTERVAL*1000)/(NUM_LEDS*DIST);//Interval is the time in milliseconds given by user
//time multiplied by 1000 to convert milliseconds to seconds since millis interprets value in milliseconds
//NUM_LEDS is total amount of LEDS, DIST is distance of the strip (in this case 25 meters)

void loop() {
if(start) {
    currentMillis = millis();
    if(currentMillis - startMillis >= period && dot < NUM_LEDS - 9) {
        leds[dot] = CRGB::Green;
        leds[dot+1] = CRGB::Green;
        leds[dot+2] = CRGB::Green;
        leds[dot+3] = CRGB::Green;
        leds[dot+4] = CRGB::Green;
        leds[dot+5] = CRGB::Green;
        leds[dot+6] = CRGB::Green;
        leds[dot+7] = CRGB::Green;
        leds[dot+8] = CRGB::Green;
        leds[dot+9] = CRGB::Green;
        leds[dot] = CRGB::Black;
        leds[dot+1] = CRGB::Black;
        leds[dot+2] = CRGB::Black;
        leds[dot+3] = CRGB::Black;
        leds[dot+4] = CRGB::Black;
        leds[dot+5] = CRGB::Black;
        leds[dot+6] = CRGB::Black;
        leds[dot+7] = CRGB::Black;
        leds[dot+8] = CRGB::Black;
        leds[dot+9] = CRGB::Black;
        startMillis = currentMillis;

I have already verified that I am getting the correct amount of seconds from the user. I believe my issue is either with my formula to calculate the period (amount of time to wait before moving the block of leds 1 pixel), or maybe my code is too bulky and the code can't loop fast enough to keep up with the period


That sketch isn't complete.

My guess is that the period, INTERVAL or DIST variable types are inappropriate but without the rest of the sketch it's impossible to say.


You set up 10 pixels green, then show them, then set the same pixels black but don't show them. is that not a bit of a waste?

Go Up