Editing LED Strip Pattern Collection

Jump to navigation Jump to search
Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then publish the changes below to finish undoing the edit.

Latest revision Your text
Line 5: Line 5:


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).
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).
Try the [https://noisebridge.net/wiki/Talk:Light_Patterns_with_LEDs_and_Arduino#Patterns LED talk page] for some great outside links!


=== Random Twinkle ===
=== Random Twinkle ===
Line 36: Line 34:
   strip.show();
   strip.show();
   delay(wait);
   delay(wait);
}
</pre>
=== Simple Wave ===
<pre>
// very simple wave: velocity, cycles,delay between frames
// simpleWave(0.03,5,10);
void simpleWave(float rate,int cycles, int wait) {
  float pos=0.0;
  // cycle through x times
  for(int x=0; x<(strip.numPixels()*cycles); x++)
  {
      pos = pos+rate;
      for(int i=0; i<strip.numPixels(); i++) {
        // sine wave, 3 offset waves make a rainbow!
        float level = sin(i+pos) * 127 + 128;
        // set color level
        strip.setPixelColor(i,(int)level,0,0);
      }
        strip.show();
        delay(wait);
  }
</pre>
=== HSV to RGB ===
Really useful function returns RGB values from Hue Saturation Brightness! From teldredge's [http://funkboxing.com/wordpress/wp-content/_postfiles/sk_qLEDFX_POST.ino FAST_SPI LED FX EXAMPLES]
<pre>
void HSVtoRGB(int hue, int sat, int val,int *colors) {
  int r, g, b, base;
// hue: 0-359, sat: 0-255, val (lightness): 0-255
if (sat == 0) { // Achromatic color (gray).
colors[0]=val;
colors[1]=val;
colors[2]=val;
} else  {
base = ((255 - sat) * val)>>8;
switch(hue/60) {
case 0:
colors[0] = val;
colors[1] = (((val-base)*hue)/60)+base;
colors[2] = base;
break;
case 1:
colors[0] = (((val-base)*(60-(hue%60)))/60)+base;
colors[1] = val;
colors[2] = base;
break;
case 2:
colors[0] = base;
colors[1] = val;
colors[2] = (((val-base)*(hue%60))/60)+base;
break;
case 3:
colors[0] = base;
colors[1] = (((val-base)*(60-(hue%60)))/60)+base;
colors[2] = val;
break;
case 4:
colors[0] = (((val-base)*(hue%60))/60)+base;
colors[1] = base;
colors[2] = val;
break;
case 5:
colors[0] = val;
colors[1] = base;
colors[2] = (((val-base)*(60-(hue%60)))/60)+base;
break;
}
}
}
}
</pre>
</pre>
Please note that all contributions to Noisebridge are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see Noisebridge:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)