Hello everyone, I am new to the world of programming - I’m working in a biomechanics lab and we developed the idea of an LED pace system using Pololu’s Addressable LEDs and an Arduino MEGA 2560. I have scoured the forums for an applicable program and have found that the “LEDStripGradient” -provided by David Grayson- in the resources section of the Addressable LED was the most conducive to work with in developing an accurate pacing system. My set-up includes 4 - 1m 30 light Addressable LED RGB strips tethered in series, pig-tails hooked into pin 12 of the Arduino MEGA 2560, a MacBook Pro running Arduino 1.0.5 connected to the MEGA 2560 via USB, and a 5V power supply powering the LED series. I have manipulated the code aforementioned above and posted it below. My problem seems to stem from understanding the “time” variable in line “byte x = time*[int] - [n]*i”. I’ve multiplied “time” by integers 1-7 and put coefficients in front of the i term in the line “byte x = time*[int] - [n]*i” to manipulate the velocity of the gradient across the 4m strand. The RGB colors write ‘Red’ to a ‘Blue’ strand and the ‘Red’ fades to purple and eventually ‘Blue’ again until the next cycle. My goal is to write the time code to be dependent on an inputted velocity (Range --> 0.5 meter/s - 10 meter/s). As I said before, this is my first project involving code and I find it daunting! Any help is greatly appreciated, thank you, kindly, in advance.
[code]/* LedStripGradient: Example Arduino sketch that shows
- how to control an Addressable RGB LED Strip from Pololu.
- To use this, you will need to plug an Addressable RGB LED
- strip from Pololu into pin 12. After uploading the sketch,
- you should see a pattern on the LED strip that fades from
- green to pink and also moves along the strip.
*/
#include <PololuLedStrip.h>
// Create an ledStrip object on pin 12.
PololuLedStrip<12> ledStrip;
// Create a buffer for holding 60 colors. Takes 180 bytes.
#define LED_COUNT 120
rgb_color colors[LED_COUNT];
void setup()
{
}
void loop()
{
// Update the colors.
byte time = millis() >> 2;
for(byte i = 0; i < LED_COUNT; i++)
{
byte x = time3 - 2.5i;
colors[i] = (rgb_color){ 2000/x , 0, x };
}
// Write the colors to the LED strip.
ledStrip.write(colors, LED_COUNT);
delay(10);
}[/code]
Best Regards,
Mikey