This is the sample code used in one or two other adafruit guides, but i've cobbled it about a bit to just have spinning circles and i'm using the Gemma board.
I do understand: the brightness setting, how to change the number of leds used, the speed of rotation and the duration of each 'case'.
I can see/change the hexadecimal value for the initial colour, but… i'm not grasping how that can be changed on the fly (what code i need) to achieve either a steady/smooth graduation across the colour spectrum or how to simply change to a specific colour value - as the leds spin.
Any help/pointers would be much appreciated.
As an aside, i had tremendous trouble getting the arduino IDE set-up to work with either the Gemma or Flora boards. I tried both ways - the simple way and the manual, moving/changing files in an existing install. I tried it on both my MacPro and MacBookPro - without success. Everything appeared to be set-up correctly, but when it came to writing files to the device I continually had avrdude errors.
Still not been able to fix the issue, but came across the codebender site, after which I was quickly able to connect and write code to the Gemma. So no idea what is going on with the arduino application… has anyone else has similar problems?
Code: Select all
// Low power NeoPixel goggles example. Makes a nice blinky display
// with just a few LEDs on at any time...uses MUCH less juice than
// rainbow display!
#include <Adafruit_NeoPixel.h>
#define PIN 0
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(32, PIN);
uint8_t mode = 0, // Current animation effect
offset = 0; // Position of spinny eyes
uint32_t color = 0x00f0ff; // Start red
uint32_t prevTime;
void setup() {
pixels.begin();
pixels.setBrightness(85); // 1/3 brightness
prevTime = millis();
}
void loop() {
uint8_t i;
uint32_t t;
switch(mode) {
case 0: // Spinny wheels (8 LEDs on at a time)
for(i=0; i<16; i++) {
uint32_t c = 0;
if(((offset + i) & 7) < 2) c = color; // 4 pixels on...
pixels.setPixelColor( i, c); // First eye
pixels.setPixelColor(31-i, c); // Second eye (flipped)
}
pixels.show();
offset++;
delay(30);
break;
case 1: // Spinny wheels (8 LEDs on at a time)
for(i=0; i<16; i++) {
uint32_t c = 0;
if(((offset + i) & 7) < 2) c = color; // 4 pixels on...
pixels.setPixelColor( i, c); // First eye
pixels.setPixelColor(31-i, c); // Second eye (flipped)
}
pixels.show();
offset++;
delay(30);
break;
}
t = millis();
if((t - prevTime) > 3000) { // Every 8 seconds...
mode++; // Next mode
if(mode > 1) { // End of modes?
mode = 0; // Start modes over
color >>= 8; // Next color R->G->B
if(!color) color = 0x00f0ff; // Reset to red
}
for(i=0; i<32; i++) pixels.setPixelColor(i, 0);
prevTime = t;
}
}