Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Here is a great way to learn the basics of programming a LED array comprised of digital strips
- //You can modify the definitions to equal the size of your matrix
- //Much thanks to the Fast_SPI Google+ Community for the help in creating this code
- #include "FastSPI_LED2.h"
- #define NUM_LEDS 90
- #define HorizontalTOTAL 10
- #define VerticalTOTAL 9
- struct CRGB leds[NUM_LEDS];
- byte sinwave[9][10]={
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,255,255,0,0,0,0 } ,
- { 0,0,0,255,180,180,255,0,0,0 } ,
- { 0,0,255,180,100,100,180,255,0,0 } ,
- { 0,255,180,100,30,30,100,180,255,0 } ,
- { 255,180,100,30,0,0,30,100,180,255 } ,
- { 180,100,30,0,0,0,0,30,100,180 } ,
- { 100,30,0,0,0,0,0,0,30,100 } ,
- { 30,0,0,0,0,0,0,0,0,30 }};
- byte lines[9][10]={
- { 255,140,85,15,0,0,0,0,0,0 } ,
- { 255,140,85,15,0,0,0,0,0,0 } ,
- { 255,140,85,15,0,0,0,0,0,0 } ,
- { 255,140,85,15,0,0,0,0,0,0 } ,
- { 255,140,85,15,0,0,0,0,0,0 } ,
- { 255,140,85,15,0,0,0,0,0,0 } ,
- { 255,140,85,15,0,0,0,0,0,0 } ,
- { 255,140,85,15,0,0,0,0,0,0 } ,
- { 255,140,85,15,0,0,0,0,0,0 }};
- byte blank[9][10]={
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,0,0,0,0,0,0 } ,
- { 0,0,0,0,0,0,0,0,0,0 }};
- byte Xshift = 0;
- byte Yshift = 0;
- byte pixel;
- byte LEDIndex;
- byte countDelay = 0;
- byte Speed = 3;
- double colorChange = 0.19;
- double color = 0.00;
- boolean colorDirection = true;
- byte sat;
- void setup(){
- // sanity check delay - allows reprogramming if accidently blowing power w/leds
- delay(2000);
- // For safety (to prevent too high of a power draw)
- LEDS.setBrightness(200);
- // Initialize your strips
- LEDS.addLeds<UCS1903, 4, RBG>(leds, NUM_LEDS); //my strips from china were wired R, B, G
- // LEDS.addLeds<WS2811, 13>(leds, NUM_LEDS);
- // LEDS.addLeds<TM1809, 13>(leds, NUM_LEDS);
- // LEDS.addLeds<TM1803, 13>(leds, NUM_LEDS);
- // LEDS.addLeds<P9813>(leds, NUM_LEDS);
- // LEDS.addLeds<LPD8806>(leds, NUM_LEDS);
- // LEDS.addLeds<WS2801>(leds, NUM_LEDS);
- // LEDS.addLeds<SM16716>(leds, NUM_LEDS);
- // LEDS.addLeds<WS2811, 11>(leds, NUM_LEDS);
- // Put ws2801 strip on the hardware SPI pins with a BGR ordering of rgb and limited to a 1Mhz data rate
- // LEDS.addLeds<WS2801, 11, 13, BGR, DATA_RATE_MHZ(1)>(leds, NUM_LEDS);
- // LEDS.addLeds<LPD8806, 10, 11>(leds, NUM_LEDS);
- // LEDS.addLeds<WS2811, 13, BRG>(leds, NUM_LEDS);
- // LEDS.addLeds<LPD8806, BGR>(leds, NUM_LEDS);
- }
- void loop() {
- if (++countDelay > Speed){
- countDelay = 0;
- if (++Xshift >= HorizontalTOTAL)
- Xshift = 0;}
- memset(leds, 0, NUM_LEDS * 3);
- color = color + colorChange;
- for (byte x = 0; x < HorizontalTOTAL; x++){
- for (byte y = 0; y < VerticalTOTAL; y++){
- //mode selection
- //pixel = blank[(y + Yshift) % VerticalTOTAL] [(x + Xshift)%HorizontalTOTAL];
- //pixel = sinwave[(y + Yshift) % VerticalTOTAL] [(x + Xshift)%HorizontalTOTAL];
- pixel = lines[(y + Yshift) % VerticalTOTAL] [(x + Xshift)%HorizontalTOTAL];
- //pixel = diamonds[(y + Yshift) % VerticalTOTAL] [(x + Xshift)%HorizontalTOTAL];
- //pixel = wave[(y + Yshift) % VerticalTOTAL] [(x + Xshift)%HorizontalTOTAL];
- sat = pixel;
- if (pixel != 0){
- LEDIndex = HorizontalTOTAL*y+(y%2)*(2*x-9)+(9-x);
- leds[LEDIndex] = CHSV(color,255,sat);}}
- }
- LEDS.show();
- delay(8);
- }
Advertisement
Add Comment
Please, Sign In to add comment