/*
* Project neoPixel
* Description: NeoPixel lesson for STEM Core
* Author: Lyell Walker
* Date: 08/16/2023
*/
#include "neopixel.h"
const int PIXELPIN = D2;
const int PIXELCOUNT = 12;
Adafruit_NeoPixel ring(PIXELCOUNT, SPI1, WS2812B);
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
int RED = 0xFF0000;
const int BLUE = 0x0000FF;
const int YELLOW = 0xFFFF00;
const int GREEN = 0x008000;
const int ORANGE = 0xFFC500;
const int INDIGO = 0x4B0082;
const int VIOLET = 0x9400D3;
const int CHARTREUSE = 0x80FF00;
const int SPRING = 0x00FF80;
const int CYAN = 0x00FFFF;
const int DODGER_BLUE = 0x0080FF;
const int PURPLE = 0x8000FF;
const int MAGENTA = 0xFF0080;
/*
HEX: #ff0000, RGB: (255, 0, 0); HEX: #ff8000, RGB: (255, 128, 0); HEX: #ffff00, RGB: (255, 255, 0)
HEX: #80ff00, RGB: (128, 255, 0); HEX: #00ff00, RGB: (0, 255, 0); HEX: #00ff80, RGB: (0, 255, 128)
HEX: #00ffff, RGB: (0, 255, 255); HEX: #0080ff, RGB: (0, 128, 255); HEX: #0000ff, RGB: (0, 0, 255)
HEX: #8000ff, RGB: (128, 0, 255); HEX: #ff00ff, RGB: (255, 0, 255); HEX: #ff0080, RGB: (255, 0, 128)
#ff0000 RGB(255, 0, 0) red Bright red
#ff8000 RGB(255, 128, 0) orange
#ffff00 RGB(255, 255, 0) yellow Yellow1
#80ff00 RGB(128, 255, 0) chartreuse
#00ff00 RGB(0, 255, 0) green Lime
#00ff80 RGB(0, 255, 128) spring green
#00ffff RGB(0, 255, 255) cyan Aqua
#0080ff RGB(0, 128, 255) dodger blue Brescian Blue
#0000ff RGB(0, 0, 255) blue Blue1
#8000ff RGB(128, 0, 255) purple
#ff00ff RGB(255, 0, 255) violet Magenta
#ff0080 RGB(255, 0, 128) magenta Neon Rose
*/
const int RAINBOW[] = {RED,ORANGE,YELLOW,CHARTREUSE,GREEN,SPRING,CYAN,DODGER_BLUE,BLUE,INDIGO,VIOLET,MAGENTA};
// Variables
int i,j,k;
// setup() runs once, when the device is first turned on.
void setup() {
// Put initialization like pinMode and begin functions here.
Serial.begin(9600);
waitFor(Serial.available,10000);
Serial.printf("Hello...our setup is done.\n");
ring.begin();
ring.clear();
ring.show();
j = 0;
k = 0;
}
// loop() runs over and over again, as quickly as it can execute.
void loop() {
// The core of your code will likely live here.
//ring.clear();
ring.setPixelColor( 3, 0xFF0000);
ring.setPixelColor( 7, 0x008000);
ring.setPixelColor(11, 0x0000FF);
ring.show();
for (j=1; j<13; j++) {
for (i=0; i<12; i++) {
k = i + j;
if (k > 12) {
k = k - 12;
}
ring.setPixelColor(k-1, RAINBOW[i]);
ring.show();
delay(20);
}
}
}
Comments