So, im working on a new project, a small game, involving a cube, with leds on each side.
i have some code working to a degree, and id like a few pointers!
i have an accelerometer giving me some xyz data, that ive mapped to 0-255, and used so if you turn the cube, whichever side is pointing up, the led fades in. this works fine.
my coding is rudimentary, and whilst ive tidied it up a bit, i have a lot of variables that ive used / experimented / deleted… ill sort this out later!
i could do with some help;
the main thing i have an issue with is when the cube is stationary (flag is state 12) for 5 seconds (breatheTime) the led will breathe (fade in and out). now the breathecode i stole from http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
and is;
float breathe = (exp(sin(millis()/2000.0*PI)) - 0.36787944)*108.0;
and this on its own works fine, but in the code i get a weird flickering, like its pulses in brightness to peak and then back down to 0.
also, the way i have the leds setup is a bit rudimentary, and theres probably a better way of doing it.
all the leds are lit all the time, but the code makes just 1 at full brightness.
for (int i = 0; i < 2; i++) {
leds[i] = CHSV( ledColour, 255, ba); // back
leds[i+2] = CHSV( ledColour, 255, le); // left
leds[i+4] = CHSV( ledColour, 255, fr); // front
leds[i+6] = CHSV( ledColour, 255, ri); // right
leds[i+8] = CHSV( ledColour, 255, to); // top
leds[i+10] = CHSV( ledColour, 255, bo); // bottom
FastLED.show();
i know this looks clumsy, and if it looks clumsy, it probably is!
(just to clarify, each side of the cube has 2 leds (and in the final product it will either have 4 leds, or 9 depending on power usage and cool factor, so some room for alteration is required!)
thanks!
