WS2811 led random effect


hey guys

i want have strip of ws2811 leds randomly flicker/strobe white (on , off not 0--> 100%). have code this. i'm using arduino uno way

thanks
ian

try start :)

code: [select]

// assuming output pin 5


const byte ledpin = 5;
const byte dur = 30; // duration of blink
const int mn = 50, mx = 1000; // interval between blinks
unsigned long strt;
unsigned long ival; // interval between blinks
byte cnt;



void setup() {
pinmode(ledpin,output);
strt = millis();
}

void loop() {
  if(cnt > 25){
    randomseed(analogread(5)); // new seed after 25 blinks
    cnt = 0;
  } 
  if(millis() - strt > ival) digitalwrite(ledpin,high);
  if(millis() - strt > ival + dur){
    digitalwrite(ledpin,low);
    ival = random(mn,mx);
    strt = millis(); cnt++;
  }
}




Arduino Forum > Using Arduino > Programming Questions > WS2811 led random effect


arduino

Comments