80 lines
3.6 KiB
Arduino
80 lines
3.6 KiB
Arduino
|
// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
|
||
|
// Released under the GPLv3 license to match the rest of the
|
||
|
// Adafruit NeoPixel library
|
||
|
|
||
|
#include <Adafruit_NeoPixel.h>
|
||
|
|
||
|
|
||
|
// Which pin on the Arduino is connected to the NeoPixels?
|
||
|
#define PIN 11 // On Trinket or Gemma, suggest changing this to 1
|
||
|
#define N 9
|
||
|
|
||
|
// How many NeoPixels are attached to the Arduino?
|
||
|
#define NUMPIXELS 9*9*N // Popular NeoPixel ring size
|
||
|
|
||
|
// When setting up the NeoPixel library, we tell it how many pixels,
|
||
|
// and which pin to use to send signals. Note that for older NeoPixel
|
||
|
// strips you might need to change the third parameter -- see the
|
||
|
// strandtest example for more information on possible values.
|
||
|
|
||
|
uint16_t map_ledA[9][9] = { { 0, 1, 2, 3, 4, 5, 6, 7, 8},
|
||
|
{ 17, 16, 15, 14, 13, 12, 11, 10, 9},
|
||
|
{ 18, 19, 20, 21, 22, 23, 24, 25, 26},
|
||
|
{ 35, 34, 33, 32, 31, 30, 29, 28, 27},
|
||
|
{ 36, 37, 38, 39, 40, 41, 42, 43, 44},
|
||
|
{ 53, 52, 51, 50, 49, 48, 47, 46, 45},
|
||
|
{ 54, 55, 56, 57, 58, 59, 60, 61, 62},
|
||
|
{ 71, 70, 69, 68, 67, 66, 65, 64, 63},
|
||
|
{ 72, 73, 74, 75, 76, 77, 78, 79, 80} };
|
||
|
|
||
|
uint16_t map_ledB[9][9] = { { 72, 73, 74, 75, 76, 77, 78, 79, 80},
|
||
|
{ 71, 70, 69, 68, 67, 66, 65, 64, 63},
|
||
|
{ 54, 55, 56, 57, 58, 59, 60, 61, 62},
|
||
|
{ 53, 52, 51, 50, 49, 48, 47, 46, 45},
|
||
|
{ 36, 37, 38, 39, 40, 41, 42, 43, 44},
|
||
|
{ 35, 34, 33, 32, 31, 30, 29, 28, 27},
|
||
|
{ 18, 19, 20, 21, 22, 23, 24, 25, 26},
|
||
|
{ 17, 16, 15, 14, 13, 12, 11, 10, 9},
|
||
|
{ 0, 1, 2, 3, 4, 5, 6, 7, 8}};
|
||
|
|
||
|
uint16_t map_led[N][9][9];
|
||
|
|
||
|
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_RGB + NEO_KHZ800);
|
||
|
|
||
|
#define DELAYVAL 200 // Time (in milliseconds) to pause between pixels
|
||
|
|
||
|
void setup() {
|
||
|
// END of Trinket-specific code.
|
||
|
for(int i=0; i<9; i++) for(int j=0; j<9; j++) map_led[0][i][j]= map_ledA[i][j] ;
|
||
|
for(int k=1; k<N; k=k+2)
|
||
|
{
|
||
|
for(int i=0; i<9; i++) for(int j=0; j<9; j++) map_led[k][i][j]= map_ledB[i][j]+81*k ;
|
||
|
for(int i=0; i<9; i++) for(int j=0; j<9; j++) map_led[k][i][j]= map_ledA[i][j]+81*k ;
|
||
|
}
|
||
|
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
|
||
|
pixels.clear(); // Set all pixel colors to 'off'
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
|
||
|
for(int i=0; i<9; i++) { // For each pixel...
|
||
|
for(int k=0; k<N; k++)
|
||
|
for(int j=0; j<9; j++)pixels.setPixelColor(map_led[k][i][j], pixels.Color(0, 150, 0));
|
||
|
pixels.show(); // Send the updated pixel colors to the hardware.
|
||
|
delay(DELAYVAL); // Pause before next pass through loop
|
||
|
for(int k=0; k<N; k++)
|
||
|
for(int j=0; j<9; j++)pixels.setPixelColor(map_led[k][i][j], pixels.Color(0, 0, 0));
|
||
|
pixels.show(); // Send the updated pixel colors to the hardware.
|
||
|
}
|
||
|
|
||
|
for(int i=0; i<9; i++) { // For each pixel...
|
||
|
for(int k=0; k<N; k++)
|
||
|
for(int j=0; j<9; j++)pixels.setPixelColor(map_led[k][j][i], pixels.Color(0, 150, 0));
|
||
|
pixels.show(); // Send the updated pixel colors to the hardware.
|
||
|
delay(DELAYVAL); // Pause before next pass through loop
|
||
|
for(int k=0; k<N; k++)
|
||
|
for(int j=0; j<9; j++)pixels.setPixelColor(map_led[k][j][i], pixels.Color(0, 0, 0));
|
||
|
pixels.show(); // Send the updated pixel colors to the hardware.
|
||
|
}
|
||
|
}
|