Guest User

Neopixel primer 1

a guest
Mar 19th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.68 KB | None | 0 0
  1. #define DDR_N (DDRB)
  2. #define PORT_N (PORTB)
  3. #define PIN_N (4)
  4.  
  5. #define BIT_SET (1 << PIN_N)
  6. #define BIT_CLR (B00000000)
  7.  
  8. #define PIXEL_COUNT 16
  9.  
  10. //NOTE: Colors = G.R.B
  11. char volatile one [ ] = "00000000.00001111.00000000";
  12.  
  13. void setup() {
  14.     DDR_N = BIT_SET;
  15.    
  16.     for(int j = 0; j < PIXEL_COUNT; j++) {
  17.         for(int i = 0; i < 26; i++) {
  18.             if(one[i] == '1') {
  19.                 PORT_N = BIT_SET;
  20.                 asm volatile (                
  21.                 "nop \n\t"
  22.                 "nop \n\t"
  23.                 "nop \n\t"
  24.                 "nop \n\t"
  25.                 "nop \n\t"
  26.                 "nop \n\t"
  27.                 "nop \n\t"
  28.                 "nop \n\t"
  29.                 "nop \n\t"
  30.                   );
  31.                 PORT_N = BIT_CLR;
  32.                 asm volatile (
  33.                 "nop \n\t"
  34.                 "nop \n\t"
  35.                 "nop \n\t"
  36.                 "nop \n\t"
  37.                 "nop \n\t"
  38.                 "nop \n\t"
  39.                 "nop \n\t"    
  40.                 );
  41.             } else if(one[i] == '0') {
  42.                 PORT_N = BIT_SET;
  43.                 asm volatile (                
  44.                 "nop \n\t"
  45.                 "nop \n\t"
  46.                 "nop \n\t"
  47.                 );
  48.                 PORT_N = BIT_CLR;
  49.                 asm volatile (                
  50.                 "nop \n\t"
  51.                 "nop \n\t"
  52.                 "nop \n\t"
  53.                 "nop \n\t"
  54.                 "nop \n\t"
  55.                 "nop \n\t"
  56.                 "nop \n\t"                  
  57.                 );
  58.             }
  59.         }
  60.     }
  61.     delayMicroseconds(7);
  62. }
  63.  
  64. void loop() {
  65.   // put your main code here, to run repeatedly:
  66. }
Add Comment
Please, Sign In to add comment