Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* HAPPY HOLIDAYS TO ALL ARDUINOS !!! */
- //modified from http://pastebin.com/wUSVNubd
- /*
- RadioShack RGB Color LED strip light show for TM1803 LED controlled LEDs.
- This began with the default code from RS - now with some annotations to help explain
- what is happening PLUS several NEW Patterns for July 4th 2014 and a change in the
- pulse timing to make it easier to adjust for MCU cycle speed (e.g. 8MHz vs 16 MHz);
- */
- #include <avr/pgmspace.h>
- // This is a "standard" include for the Arduino IDE that provides functions needed (like PROGMEM, etc.)
- /*
- #define DATA_1 (PORTD |= (1<<5)) // Set logic high Pin5 of Port D
- #define DATA_0 (PORTD &= ~(1<<5)) // Set Pin5 logic low Pin5 of Port D
- #define STRIP_PINOUT DDRD |= (1<<5) // Set Pin5 of PortD as digital output
- #define LED_RGB_STRIP
- */
- #define DATA_1 (PORTC |= 0X01) // DEFINE a value for DATA as 1 // for UNO
- #define DATA_0 (PORTC &= 0XFE) // DEFINE a value for DATA 0 // for UNO
- #define STRIP_PINOUT (DDRC=0x3F) // DEFINE PORTC as OUTPUT // for UNO (change pins 0-5; leave PORTC 6 & 7 alone)
- #define NOP "nop\n\t"
- /*
- Each 'nop' statement executes in one machine cycle (at 16 MHz) yielding a 62.5 ns (nanosecond) delay.
- __asm__("nop\n\t");
- __asm__("nop\n\t""nop\n\t""nop\n\t""nop\n\t");// Synatax for multiple Delays
- */
- /*
- Create an array of values [xx] by [nn] to control each LED NODE in the standard RadioShack strip.
- [xx] is the number of FRAMES in your sequence and [nn] is the number of NODES for YOUR LED strip, usually 10.
- PROGMEM stores the data in the AVR chip's PROGRAM memory. This has much more space than the 2K of variable RAM memory.
- The two dimensional array has one value for each one of the 10 TM1803 RGB LEDs - controlling the color.
- Each "row" can change the colors assigned. This is like a FRAME in an animation. Changing the FRAME's
- values and patterns can create the animation effect of motion.
- We will then read out these values one FRAME (row) at a time to create the 24bit serial pulse train that is OUTPUT to the LED Strip.
- Each ROW is sent as OUTPUT and it will SET the COLOR for each of the TEN (10) nodes.
- Each ROW is a NEW FRAME, changing the colors again and again, creating a pattern.
- The order of the HEX doublets (bytes) controlling the COLORS is: Green - Blue - Red.
- ff is full brightness - so 0xff0000 is full GREEN, 0xx00ff00 is full BLUE, 0x0000ff is full RED
- */
- // In the Radio Shack RGB Strip, the TM1803 controls RED with the last HEX byte
- PROGMEM const unsigned long chasing_red[][10]={
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- };
- PROGMEM const unsigned long first_red[][10]={
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- };
- PROGMEM const unsigned long second_red[][10]={
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x0000f0},
- };
- PROGMEM const unsigned long first_white[][10]={
- {0xd0d0d0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x0000f0},
- {0x000000,0xd0d0d0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x0000f0},
- {0x000000,0x000000,0xd0d0d0,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0xd0d0d0,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x000000,0x000000,0x000000,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x000000,0x000000,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x000000,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- };
- PROGMEM const unsigned long second_white[][10]={
- {0xd0d0d0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0xd0d0d0,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0xd0d0d0,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0xd0d0d0,0x000000,0x000000,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x000000,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0x000000,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- };
- PROGMEM const unsigned long first_blue[][10]={
- {0x00f000,0x000000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x00f000,0x000000,0x000000,0x000000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x00f000,0x000000,0x000000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x00f000,0x000000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x00f000,0x000000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x00f000,0x000000,0x000000,0x000000,0x000000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x00f000,0x000000,0x000000,0x000000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x00f000,0x000000,0x000000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x00f000,0x000000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- };
- PROGMEM const unsigned long second_blue[][10]={
- {0x000000,0x000000,0x000000,0x000000,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x0000f0,0x000000,0x000000,0x000000,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x0000f0,0x000000,0x000000,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x0000f0,0x000000,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x000000,0x0000f0,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x0000f0,0x000000,0x000000,0x0000f0,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x0000f0,0x000000,0x0000f0,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0x000000,0x000000,0x0000f0,0x0000f0,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- {0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0,0x00f000,0x00f000,0xd0d0d0,0xd0d0d0,0x0000f0,0x0000f0},
- };
- // In the Radio Shack RGB Strip, the TM1803 controls GREEN with the 1st, BLUE with the 2nd, and RED with the last HEX byte,
- PROGMEM const unsigned long red_white_blue[][10]={
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0xd0d0d0,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x00f000,0xd0d0d0,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x00f000,0xd0d0d0,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x00f000,0xd0d0d0,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x00f000,0xd0d0d0,0x0000f0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x00f000,0xd0d0d0,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0xd0d0d0,0x0000f0,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0xd0d0d0,0x0000f0,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0xd0d0d0,0x0000f0},
- };
- // WHITE is ALL HEX bytes (can vary the "color" of white by changing these
- PROGMEM const unsigned long chasing_white[][10]={
- {0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0xfdfdfd,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xfdfdfd,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xfdfdfd,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xfdfdfd,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xfdfdfd},
- };
- // BLUE is the second HEX byte
- PROGMEM const unsigned long chasing_blue[][10]={
- {0x00f000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x00f000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x00f000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x00f000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x00f000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x00f000},
- };
- // GREEN is the first HEX byte
- PROGMEM const unsigned long chasing_green[][10]={
- {0xf00000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0xf00000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0xf00000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0xf00000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0xf00000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0xf00000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xf00000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xf00000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xf00000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xf00000},
- };
- // Each ROW changes which LED is bright, creating a moving pattern
- PROGMEM const unsigned long pattern_test_comet1[][10]={
- {0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xfdfdfd},
- };
- PROGMEM const unsigned long pattern_test_comet2[][10]={
- {0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000},
- {0x444444,0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000},
- {0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000},
- {0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000},
- {0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd},
- {0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000},
- {0x444444,0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000},
- {0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000},
- {0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000},
- {0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x111111,0x444444,0xfdfdfd},
- };
- PROGMEM const unsigned long pattern_test_comet3[][10]={
- {0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xfdfdfd},
- {0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0xfdfdfd,0x444444},
- {0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0x000000,0x000000,0xfdfdfd,0x444444,0x111111},
- {0x000000,0x111111,0x444444,0xfdfdfd,0x000000,0x000000,0xfdfdfd,0x444444,0x111111,0x000000},
- {0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0xfdfdfd,0x444444,0x111111,0x000000,0x000000},
- {0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0xfdfdfd,0x444444,0x111111,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0xfdfdfd,0x444444,0x444444,0xfdfdfd,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0xfdfdfd,0x444444,0x111111,0x111111,0x444444,0xfdfdfd,0x000000,0x000000},
- {0x000000,0xfdfdfd,0x444444,0x111111,0x000000,0x000000,0x111111,0x444444,0xfdfdfd,0x000000},
- {0xfdfdfd,0x444444,0x111111,0x000000,0x000000,0x000000,0x000000,0x111111,0x444444,0xfdfdfd},
- };
- // Each row changes the color and intensity of the LEDs
- PROGMEM const unsigned long rainbow1[][10]={
- {0xfd0000,0xfd7f00,0xfdfd00,0x00fd00,0x0000fd,0x6f00fd,0x8f00fd,0x000000,0x000000,0x000000},
- {0x000000,0xfd0000,0xfd7f00,0xfdfd00,0x00fd00,0x0000fd,0x6f00fd,0x8f00fd,0x000000,0x000000},
- {0x000000,0x000000,0xfd0000,0xfd7f00,0xfdfd00,0x00fd00,0x0000fd,0x6f00fd,0x8f00fd,0x000000},
- {0x000000,0x000000,0x000000,0xfd0000,0xfd7f00,0xfdfd00,0x00fd00,0x0000fd,0x6f00fd,0x8f00fd},
- {0x8f00fd,0x000000,0x000000,0x000000,0xfd0000,0xfd7f00,0xfdfd00,0x00fd00,0x0000fd,0x6f00fd},
- {0x6f00fd,0x8f00fd,0x000000,0x000000,0x000000,0xfd0000,0xfd7f00,0xfdfd00,0x00fd00,0x0000fd},
- {0x0000fd,0x6f00fd,0x8f00fd,0x000000,0x000000,0x000000,0xfd0000,0xfd7f00,0xfdfd00,0x00fd00},
- {0x00fd00,0x0000fd,0x6f00fd,0x8f00fd,0x000000,0x000000,0x000000,0xfd0000,0xfd7f00,0xfdfd00},
- {0xfdfd00,0x00fd00,0x0000fd,0x6f00fd,0x8f00fd,0x000000,0x000000,0x000000,0xfd0000,0xfd7f00},
- {0xfd7f00,0xfdfd00,0x00fd00,0x0000fd,0x6f00fd,0x8f00fd,0x0000fd,0x00fd00,0xfdfd00,0xfdfd00},
- };
- PROGMEM const unsigned long cylon_test_red[][10]={
- {0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0xf0f0f0,0x000000,0x000000,0x000000,0x000000,0x000000},
- };
- PROGMEM const unsigned long red_cylon_R[][10]={
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- };
- PROGMEM const unsigned long red_cylon_L[][10]={
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000},
- };
- PROGMEM const unsigned long star_trek_bridge[][10]={
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0x0000f0,0xf000f0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x000000,0xd000d0,0xd000d0,0x000000,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000},
- {0x000000,0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000,0x000000},
- {0x000000,0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0,0x000000},
- {0x0000f0,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x000000,0x0000f0},
- };
- // ***********************************************************************************************************
- // * INITIALIZE the system on Power Up or after a RESET
- // *
- // ***********************************************************************************************************
- void setup() {
- STRIP_PINOUT; // sets the output pin to control the LED Strip
- reset_strip(); // resets each of the LED nodes to OFF
- }
- // ***********************************************************************************************************
- // * Main Program Loop
- // *
- // ***********************************************************************************************************
- void loop()
- {
- /*
- This is a TEST PATTERN to show that all of the
- segments ("nodes") are working properly.
- This Runs Only ONCE ... because the next loop
- never finishes.
- You could remove the WHILE loop and then these patterns
- would run continuously, as long as there is power to the board.
- */
- /* CHASING PRIMARY COLORS */
- int q = 1;
- send_1M_pattern(chasing_green, 10, 50);
- delay(500);
- send_1M_pattern(chasing_blue, 10, 500);
- delay(500);
- send_1M_pattern(chasing_red, 10, 500);
- delay(500);
- /* CHASING WHITE */
- send_1M_pattern(chasing_white, 10, 500);
- delay(500);
- send_1M_pattern(pattern_test_comet1, 10, 70);
- delay(500);
- send_1M_pattern(pattern_test_comet2, 10, 70);
- delay(500);
- send_1M_pattern(pattern_test_comet3, 10, 70);
- delay(500);
- /* RAINBOW TEST PATTERN */
- send_1M_pattern(rainbow1, 10, 100);
- delay(1000); // Wait for one second to make you think about the infinite loop
- /* TEN CYCLES OF TREK BRIDGE */
- q = 10;
- while (q>0){
- send_1M_pattern(star_trek_bridge, 10, 50);
- q -= 1;
- }
- delay(500);
- /*
- Use this to control which pattern is sent to the
- LED Strip.
- This loop runs will run continuously inside the "master" loop;
- because the value of WHILE (1) never changes. You may elminate this,
- or add your own control program.
- */
- while (1)
- {
- send_1M_pattern(chasing_white, 10, 100);
- delay(500);
- send_1M_pattern(rainbow1, 10, 100);
- delay(500);
- send_1M_pattern(chasing_green, 10, 50);
- delay(1000); // Wait for one second to make you think about the infinite loop
- /* RAINBOW TEST PATTERN */
- send_1M_pattern(rainbow1, 10, 100);
- delay(1000); // Wait for one second to make you think about the infinite loop
- /* TEN CYCLES OF CYLON */
- q = 10;
- while (q>0){
- send_1M_pattern(cylon_test_red, 10, 100);
- delay(500);
- send_1M_pattern(red_cylon_R, 10, 70);
- send_1M_pattern(red_cylon_L, 10, 70);
- q -= 1;
- }
- delay(500);
- /* 5 CYCLES OF SIMPLE RED-WHITE-BLUE */
- q = 5;
- while (q>0){
- send_1M_pattern(chasing_red, 10, 100);
- delay(500);
- send_1M_pattern(chasing_white, 10, 100);
- delay(500);
- send_1M_pattern(chasing_blue, 10, 100);
- delay(500);
- q -= 1;
- }
- delay(500);
- /* FIVE CYCLES OF TREK BRIDGE */
- q = 5;
- while (q>0){
- send_1M_pattern(star_trek_bridge, 10, 60);
- q -= 1;
- }
- delay(500);
- /* 10 CYCLES CHASING RED-WHITE-BLUE */
- q = 10;
- while (q>0){
- send_1M_pattern(red_white_blue, 10, 100);
- delay(300);
- q -= 1;
- }
- delay(500);
- /* 10 CYCLES OF RED-WHITE-BLUE BUILD UP */
- q = 10;
- while (q>0){
- send_1M_pattern(first_red, 10, 100);
- delay(500);
- send_1M_pattern(second_red, 10, 100);
- delay(500);
- send_1M_pattern(first_white, 10, 100);
- delay(500);
- send_1M_pattern(second_white, 10, 100);
- delay(500);
- send_1M_pattern(first_blue, 10, 100);
- delay(250);
- send_1M_pattern(second_blue, 10, 100);
- delay(500);
- q -= 1;
- }
- delay(500);
- /* 10 CYCLES CHASING RED-WHITE-BLUE */
- q = 10;
- while (q>0){
- send_1M_pattern(red_white_blue, 10, 100);
- delay(300);
- q -= 1;
- }
- delay(500);
- } // END OF WHILE (1);
- } // END OF VOID LOOP() - In standard C++ otherwise known as MAIN();
- /*******************************************************************************
- * Function Name: send_1M_pattern
- * Description: Transmit pattern to whole 1 meter strip
- * Input : Pointer to RAM pattern; pattern length; frame rate
- * Output: Sends out a serial pulse train using the send_strip function
- * Return: None
- *******************************************************************************/
- void send_1M_pattern(const unsigned long data[][10], int pattern_no, int frame_rate)
- {
- int i=0;
- int j=0;
- uint32_t temp_data;
- // data[][10] is the name of the ARRAY with the RGB LED pattern values
- // Each pattern sends out [x] packets - one for each NODE (RGB LED cluster) in the strip
- // pattern_no is the [y] dimension of the array - the number of ROWS in each pattern array series
- // frame_rate is the DELAY before transmitting the next ROW in the pattern array
- for (i=0;i<pattern_no;i++)
- {
- noInterrupts(); // Turn OFF Interupts for more precise Pulse Timing using MCU processing cycles
- for (j=0;j<10;j++)
- {
- temp_data=pgm_read_dword_near(&data[i][j]);
- send_strip(temp_data);
- }
- interrupts(); // Turn ON Interrupts after data is sent
- delay(frame_rate); // Delay between each pulse train - sets the duration of each FRAME, before the next series is sent;
- /* CONTROLS THE VISUAL SPEED OF THE DISPLAY CHANGES */
- }
- }
- /*******************************************************************************
- * Function Name: send_strip
- * Description: Creates and Transmits a serial train of 24 pulses for the LED strip
- * Input: 24-bit data sets intensity of each color, which will persist until
- * the next cycle makes a change
- * Output: Sends a train of 24 pulses (bits) representing values of 0 or 1 to the output pin ()
- * TIMING the OUTPUT pulses using the duration of the MCU NOP @ 16MHz
- * Return: Nothing returned from function
- *******************************************************************************/
- void send_strip(uint32_t data)
- {
- int i;
- unsigned long j=0x800000;
- int d;
- for (i=0;i<24;i++)
- {
- if (data & j)
- {
- DATA_1;
- // TM1803 BIT 1 - Set OUTPUT PIN HIGH & HOLD FOR 1.55us or ~ 26 MCU CYCLES = 1.625us;
- // The comparison (d<NN) uses ONE cycle, so the total delay is 2 X d X NOP (62.5 Nanoseconds);
- for (d=1;d<13;d++)
- {
- __asm__(NOP);
- }
- DATA_0; // Set OUTPUT PIN LOW ;
- }
- else
- {
- DATA_1;
- // TM1803 BIT 0 - Set OUTPUT PIN HIGH & HOLD FOR 0.78us or ~ 12 MCU CYCLES = .750us;
- // The comparison (d<NN) uses ONE cycle, so the total delay is 2 X d X NOP (62.5 Nanoseconds);
- for (d=1;d<5;d++)
- {
- __asm__(NOP);
- }
- DATA_0; // Set OUTPUT PIN LOW ;
- /*----------------------------*/
- __asm__(NOP);
- __asm__(NOP);
- __asm__(NOP);
- /*----------------------------*/
- }
- j>>=1;
- }
- }
- // END of send_strip();
- /*******************************************************************************
- * Function Name: reset_strip
- * Description: Send a 0 pulse to reset all colors on all NODES of the strip
- * Input: None
- * Output: Sends out a looong duration 0 on the OUTPUT PIN to RESET the TM1803 chips
- * Return: None
- *******************************************************************************/
- void reset_strip()
- {
- DATA_0;
- delayMicroseconds(20); // TM1803 specifies >= 24uS; // Arduino delay is actually slightly longer than assembler execution
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement