Go Down

Topic: Programming Question (Read 416 times) previous topic - next topic

oaxacamatt1

Hi All,
I have a programming question, probably simple to some... (but not for me)

I have set up my Arduino with 6 leds (outputs = 3,5,6,9,10,11) for PWM on my breadboard.  That is ok.

What I would like to do is have a program that increases the led intensity like a bell curve moving like a wave front down the line of leds.  I would like to have that wave loop continously.  

In other words, I am trying to set up the led intensities to scroll or loop (i=intensity,  i, i+1, i+2, i+3, i+3, i+2, i+1, i).  I am little baffled on how to have this loop around.

Oaxacamatt1

westfw

how about something like this:

Code: [Select]

unsigned char bellcurve[8];
int pins[6] = {3,5,6,8,10,11};
int startpos = 0; // which item from bellcurve goes on first LED.

calculate_intensities();  //fills in bellcurve
 bell_idx = startpos;
for (i=0; i < 6; i++) {   // output bellcurve (part) to LEDs
 if (bell_idx > 7)
   bell_idx = 0;
 analogWrite(pins[i], bellcurve[bell_idx]);
 bell_idx += 1;
}


Go Up