New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FastLED.show() causes servo to twitch #619

Open
tomchambers2 opened this Issue Jun 27, 2018 · 2 comments

Comments

Projects
None yet
2 participants
@tomchambers2

tomchambers2 commented Jun 27, 2018

When running FastLED.show() every 50 miliseconds (by measuring the delta rather than with a delay) and having a servo attached without the servo being sent any code, the servo twitches. This only happens when .show() is fired.

#include <Servo.h>
#include <FastLED.h>

#define LED_TYPE    WS2812B
#define LED_STRIP_PIN     6
#define NUM_LEDS    100
#define COLOR_ORDER GRB
#define LED_UPDATE_TIME 50

int lastLedUpdate = 0;

CRGB leds[NUM_LEDS];

Servo servo;

setup() {
  servo.attach(10);
  FastLED.addLeds<LED_TYPE, LED_STRIP_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
  FastLED.show();  
}

loop() {
  if (millis() - lastLedUpdate < LED_UPDATE_TIME) return;

  lastLedUpdate = millis();

  FastLED.clear();
  
  for (int i = 0; i <= NUM_LEDS; i++) {
    leds[i] = CRGB::Red;
  }

  FastLED.show();
}
@focalintent

This comment has been minimized.

Member

focalintent commented Jun 27, 2018

Unfortunately, servos are driven by interrupts which get disabled while writing out ws2812 data. Either switch to an led chipset that doesn’t require disabling interrupts like the apa102 or switch to a platform that allows interrupts to run while writing out led data like the teensy 3.x.

@focalintent

This comment has been minimized.

Member

focalintent commented Jun 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment