Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- RadioShack Tri Color LED strip light show.
- This began as the default code from RS - but some annotations to help explain
- what is happening have been added, as well as some new patterns.
- */
- #include <avr/pgmspace.h>
- // ******** DEBUG ==== should auto config to adapt different mother board *********
- //#define DATA_1 (PORTF |= 0X01) // DATA 1 // for ATMEGA
- //#define DATA_0 (PORTF &= 0XFE) // DATA 0 // for ATMEGA
- //#define STRIP_PINOUT DDRF=0xFF // for ATMEGA
- #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)
- /*
- This PORT command uses the OUTPUT pin as in the RadioShack manual for these strips: A0
- I think RS chose A0 because the adjacent pins on the UNO are GND and Vin (12V)
- This puts all three wires together - even though out of order. You may, of course,
- change the PORT command and send the data output to another PORT and PIN. You might,
- for example, send the output to one of the Digital PORTs.
- */
- /*
- Create an array of values to control each LED NODE in the standard RadioShack strip.
- PROGMEM will assign values to store in the AVR chip's RAM memory as a two dimensional array.
- We will then read out these values to create a serial pulse train OUTPUT to the LED Strip.
- Each ROW is sent as OUTPUT and 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 data is sent to the strip as 24 bits (3 bytes, each with two HEX digits of 0-f).
- 0x specifies a HEXADECIMAL number
- The order of the bytes (two HEX digits) that control the intensity of the primary COLORS is:
- Green - Blue - Red (NOT RGB as is incorrectly mentioned in the RS instructions). ff is full
- brightness and 00 is "off" for each color:
- so 0xff0000 is GREEN; 0xx00ff00 is BLUE; and, 0x0000ff is RED.
- */
- // RED is the last HEX "doublet" (byte)
- PROGMEM const unsigned long pattern_test_red[10][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},
- };
- // WHITE is ALL HEX "doublets" (bytes) full "on"
- PROGMEM const unsigned long pattern_test_white[10][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 "doublet" (byte)
- PROGMEM const unsigned long pattern_test_blue[10][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 "doublet" (byte)
- PROGMEM const unsigned long pattern_test_green[10][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 is like an animation FRAME, and changes the LED intensity, creating a pattern
- // As each ROW in the array pattern changes, from FRAME to FRAME, it creates the illusion
- // of motion for the LEDs.
- 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 ("frame") changes the color and intensity of the LEDs creating a rainbow pattern
- PROGMEM const unsigned long pattern_test_rainbow[10][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][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][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,0xf000f0,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},
- };
- // ***********************************************************************************************************
- // *
- // * 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.
- */
- int q = 1;
- send_1M_pattern(pattern_test_red, 10, 500);
- delay(500);
- send_1M_pattern(pattern_test_white, 10, 500);
- delay(500);
- send_1M_pattern(pattern_test_blue, 10, 500);
- delay(500);
- send_1M_pattern(pattern_test_green, 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);
- send_1M_pattern(pattern_test_green, 10, 500);
- delay(1000); // Wait for one second to make you think about the infinite loop
- /* TEN CYCLES OF TREK BRIDGE */
- q = 20;
- while (q>0){
- send_1M_pattern(star_trek_bridge, 10, 30);
- q -= 1;
- }
- delay(500);
- /*
- Use this to control which pattern is sent to the
- LED Strip.
- This loop runs will run continously inside the "master" loop;
- because the value of WHILE (1) never changes.
- */
- while (1)
- {
- send_1M_pattern(pattern_test_white, 10, 500);
- delay(500);
- send_1M_pattern(pattern_test_rainbow, 10, 70);
- delay(500);
- send_1M_pattern(pattern_test_green, 10, 500);
- delay(1000); // Wait for one second to make you think about the infinite loop
- send_1M_pattern(cylon_test_red, 10, 70);
- delay(500);
- /* TEN CYCLES OF CYLON */
- q = 10;
- while (q>0){
- send_1M_pattern(red_cylon_R, 10, 70);
- send_1M_pattern(red_cylon_L, 10, 70);
- q -= 1;
- }
- delay(500);
- /* TEN CYCLES OF TREK BRIDGE */
- q = 20;
- while (q>0){
- send_1M_pattern(star_trek_bridge, 10, 30);
- q -= 1;
- }
- delay(500);
- send_1M_pattern(pattern_test_blue, 10, 70);
- delay(500);
- }
- }
- /*******************************************************************************
- * 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;
- // Each pattern sends out [x] packets - one for each NODE (RGB LED cluster)
- // pattern_no is the [y] dimension of the array - the number of ROWS in each pattern array set
- for (i=0;i<pattern_no;i++)
- {
- noInterrupts(); // Turn OFF Interupts for more precise Pulse Timing
- 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 signal 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 ()
- * Return: Nothing returned from function
- *******************************************************************************/
- void send_strip(uint32_t data)
- {
- int i;
- unsigned long j=0x800000;
- for (i=0;i<24;i++)
- {
- if (data & j)
- {
- DATA_1;
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- /*----------------------------*/
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- /*----------------------------*/
- DATA_0;
- }
- else
- {
- DATA_1;
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- DATA_0;
- /*----------------------------*/
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- __asm__("nop\n\t");
- /*----------------------------*/
- }
- j>>=1;
- }
- }
- /*******************************************************************************
- * Function Name: reset_strip
- * Description: Send a 0 pulse to reset all color of the strip*
- * Input: None*
- * Output: Sends out a looong value of 0 on the output pin
- * Return: None
- *******************************************************************************/
- void reset_strip()
- {
- DATA_0;
- delayMicroseconds(20);
- }
Add Comment
Please, Sign In to add comment