OK, I'm a complete novice to electronics, and micro controllers, let's get that straight right from the start. Also, I'm new to the board, so if I've posted this in the wrong place I'm very sorry - go easy on me.

I recently bought a Arduino Duemilanove from the very helpful guys over at Oomlaut because I decided that I wanted to learn something new, and maybe try and develop my creative side.

I've been messing around with a few simple projects - probably the usual stuff that a noob like me does to get his hands dirty. My task for this evening was to try and simulate a PWM style brightness control on 8 LEDs driven through a 74HC595 shift register.

OK, first off, the circuit is basically identical to that shown here http://ardx.org/CIRC05 although my layout is slightly different just to get the LEDs in a straight line.

// Pattern of BITs that we use to determine if an LED gets power this cycle or not// The more 1 BITs in the pattern, the brighter the LED will be overall.// The 1's are spread as much as possible in order to try and reduce flicker.byte brightnessPattern[] = {B00000000, B00000001, B00010001, B01010101, B11111111};

// BIT mask used to look at an individual BIT in the brightnessPattern[],// also to set the individual BIT for the LEDbyte bitMask[] = {B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000};

If your looking to do PWM via the Shift Register .. here is some code that allows you to configure the number of Shift Registers you have .. then use pwmWrite(port,value) .. with value being from 0 to 255.

The code is setup to handle multiplexing .. but configured to not use it.

The code is setup to handle multiple SR's .. but configured to use one.

I also have an RGBCommonLED class that integrates with this .. allowing you to set hue using 0-255 value (instead of 0-360), which makes to make it easier to set / use with a byte value (important when you have so few bytes to work with).

You can find that by searching my other posts .. or I can provide a fuller example with that if you like .. just did not want to post something too complex right off .. often just not used / loaded in that case.

Finding Parts:Found Shift Registers on e-bay .. $18 shipped for 50 of them.Found $25/$28 shipped for 100 RGB Common anode. Ones shipped from china took longer .. but they included the right resistors with labels and the order was RGB .. not RBG as in some cases. Make sure you ask for the resistors with your order .. and say for 5v or you may not get them (except the china sources seem to be good with that).

//--- Some really basic stuff .. just to run through some simple tasks for( int iPort = 0 ; iPort < 3 ; iPort++ ){ delay(200); for (int i = 0 ; i < 255 ; i++){ //--- set RGB LED 1 color x pwmWrite(iPort,i); //--- set RGB LED 2 color x without a reset pwmWrite(iPort+3,i); delay(10); } //-- reset only the first LED .. makeing the second one turn all white by the end of third run //* simple way to show some color mixing pwmWrite(iPort,0);

Thanks Marklar, I'm not in the least bit surprised that there is a much better and more accurate way to achieve a similar goal. I've only had a chance to quickly look at the code, and I don't fully understand it all yet. I'll run it on my Arduino tonight and see if I can begin to understand how it does what it does. I haven't looked at interrupts and timers at all yet, so that's something new for me to get to grips with.

I have a relatively easy supplier of the 74HC595s as there is an electronics warehouse next to my office which is fairly competitive on price, but they strangely don't seem to stock RGB LEDs.

Anyway, I'll see if I can get to grips with your code, try it out with a few simple circuits/patterns on single colour LEDs and take it from there.

Thanks MikMo. I'm single by choice (bloody women, eating into my play time and spending my hard earned cash!), I'd love to kiss my job goodbye, and the less I'm bothering my daughter the better as far as she is concerned.

This wasn't my first project. After the usual blinking LED stuff, I created an electronic dice from scratch just to learn a few basics. Worked quite well I thought, then I found a few schematics and sketches for other peoples and I quietly tucked it away. [smiley=cry.gif] I then created a digital thermometer that displayed the temp on a pair of 7 segment LED displays. Again I was quite chuffed with the results.

I'm also working on plans for a very long duration time-lapse camera thingy, I want it to run as unattended as possible for up to a year. First step is that I need to find a cheap digital camera I can hack up a bit. Currently scouring ebay.

• Upload doesn't work? Do a loop-back test.• There's absolutely NO excuse for not having an ISP!• Your AVR needs a brain surgery? Use the online FUSE calculator.• My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...• Microsoft is not the answer. It is the question, and the answer is NO!

I was referring to the datasheet of the ATmega168/328 microcontroller.

http://www.atmel.com/dyn/resources/prod_documents/doc8271.pdf

The PDF is about 22MB and you'll find everything you need starting on page 167.

• Upload doesn't work? Do a loop-back test.• There's absolutely NO excuse for not having an ISP!• Your AVR needs a brain surgery? Use the online FUSE calculator.• My projects: RGB LED matrix, RGB LED ring, various ATtiny gadgets...• Microsoft is not the answer. It is the question, and the answer is NO!