EDIT: posted this before i saw Mikals post. thanks. ill have to give that a try!
so messing around with PWMAllPins i got this:
float pwmSpeed[17] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; // these constants set the rate of dimming
int pwmVal[14]; // PWM values for 12 channels - 0 & 1 included but not used
float pwmFloats[14];
int i, j, k, l, x, y, z, bufsize, pot; // variables for various counters
unsigned char sinewave[] = //256 values
{
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,0x60,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20
};
void setup(){
Serial.begin(9600);
DDRD=0xFC; // direction variable for port D - make em all outputs except serial pins 0 & 1
DDRB=0xFF; // direction variable for port B - all outputs
}
void loop(){
// time = millis(); // this was to test the loop speed
// for (z=0; z<1000; z++){ // ditto
// pot = analogRead(0); // this implemented a potentiometer speed control to control speed of fading
for (y=0; y<14; y++){ // calculate one new pwm value every time through the control loop
j = (j + 1) % 12; // calculate a new j every time - modulo operator makes it cycle back to 0 after 11
k = j + 2; // add 2 tp tje result - this yields a cycle of 2 to 13 for the channel (pin) select numbers
pwmFloats[k] = (pwmFloats[k] + pwmSpeed[k]);
// pwmFloats[k] = (pwmFloats[k] + ((pwmSpeed[k] * 15 * (float)pot) / 1023)); // implements potentiometer speed control - see line above
if (pwmFloats[k] >= 256){ // wrop around sinewave table index values that are larger than 256
pwmFloats[k] = pwmFloats[k] - 256;
}
else if (pwmFloats[k] < 0){
pwmFloats[k] = pwmFloats[k] + 256; // wrop around sinewave table index values that are less than 0
}
pwmVal[k] = sinewave[(int)pwmFloats[k]]; // convert the float value to an integer and get the value out of the sinewave index
}
PORTD = 0xFC; // all outputs except serial pins 0 & 1
PORTB = 0xFF; // turn on all pins of ports D & B
for (z=0; z<3; z++){ // this loop just adds some more repetitions of the loop below to cut down on the time overhead of loop above
// increase this until you start to preceive flicker - then back off - decrease for more responsive sensor input reads
for (x=0; x<256; x++){
for( i=2; i<14; i++){ // start with 2 to avoid serial pins
if (x == pwmVal[i]){
if (i < 8){ // corresponds to PORTD
// bitshift a one into the proper bit then reverse the whole byte
// equivalent to the line below but around 4 times faster
// digitalWrite(i, LOW);
PORTD = PORTD & (~(1 << i));
}
else{
PORTB = PORTB & (~(1 << (i-8))); // corresponds to PORTB - same as digitalWrite(pin, LOW); - on Port B pins
}
}
}
}
}
// }
// Serial.println((millis() - time), DEC); // speed test code
}
which blinks an LED through 3 different brightness levels.
i dont totally understand the
float pwmSpeed[17] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
seems like if i set it anything besides 0 they blink the same. it was originally pwmSpeed[14] but it seems the more values in the array the longer it takes to go through the different levels of brightness. when i try to add output to PORTC things get screwy. if you mess around with this and get it to work on all pins in all ports let me know please
and if you figure out how to get to animate like i said previously in the post you will be my hero