Hi I posted yesterday about a project my friends and I are doing for a college project using shiftout and 74HC595 chips. We currently have a way of turning on and off the leds colours but we are trying to figure out how to get pwm to work with them. Has anyone done this before?
I've never done this, but I would approach it this way:
First, learn how to do PWM for individual LEDs on the individual pins of the Arduino using digital writes or direct port access.
Then, substitute an appropriately sized variable (byte, integer, char array?) for the pins, and use bit operators to change the value in the variable in the same manner (this will be similar to a direct port manipulation implementation in item 1 above).
After changing the value in the variable, each time through your PWM loop, dump the value to the 595 and latch it across. This part of the code will need to be written to be fairly efficient, if you don't want any flicker.
I hope that made sense; basically you are doing bit manipulation on a variable to change its value, where you are toggling each bit each time thru the PWM loop at the rate for the PWM of that bit, then clocking/latching that new value out to the 595 each time thru the loop. If you have multiple 595s, you will need a method to allow you to manipulate more bits (with larger size variable, or a char array - for instance, one 32 bit integer could be used then banged out to four 595s daisy chained then latched across to the LEDs).