LED Strip Pattern Collection

From Noisebridge
Revision as of 19:34, 20 July 2013 by Dana (talk | contribs) (Created page with "Note: Some of these may be written specifically for octows2811, neopixel or fastSPI, but it's usually easy to port between them (change the show and set color functions). ===...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Note: Some of these may be written specifically for octows2811, neopixel or fastSPI, but it's usually easy to port between them (change the show and set color functions).

Random Twinkle

// number, twinkle color, background color, delay
// twinkleRand(5,strip.Color(255,255,255),strip.Color(255, 0, 100),90);

// twinkle random number of pixels
void twinkleRand(int num,uint32_t c,uint32_t bg,int wait) {
	// set background
	 stripSet(bg,0);
	 // for each num
	 for (int i=0; i<num; i++) {
	   strip.setPixelColor(random(strip.numPixels()),c);
	 }
	strip.show();
	delay(wait);
}

Set All Pixels Quickly

// quickly set the entire strip a color
void stripSet(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
  }
  // move the show outside the loop
  strip.show();
  delay(wait);
}