As part of my quest to replace every single bulb in my Alfa with an LED equivalent, I noticed that the high level brake light utilised small bulbs and not LEDs (strange I know, but that’s Alfa for you!). So me being me, I took it apart and found that it would be very easy to replace the bulbs with LEDs whcih was a result. Of course, this wasn’t enough so I thought, If I had 10 LEDs what could I do with them 🙂
Enter the ATMega328 MCU, or as you may know it, the Arduino 🙂
The ATMega328 has 14 Digital Pins, 6 of which are PWM and an additional 6 x analogue inputs, problem is I needed 10 x PWM pins. The best option in this case is to use a shift register such as a 595 to extend your pins, but as I didn’t have one to hand, I decided to do it the hard way. There is a software library for the arduino SDK called : SoftPWM.h which lets you simulate PWM on any pin, which is quite useful to limit the hardware used and make better use of the processing power of the chip. So 4 hours of “figuring it out” yielded this result:
The basic functional requirement was simple:
- When the brake pedal is pressed illuminate as normal
- If the pedal is pressed for more than 5 seconds get your cylon on 🙂
You can download the sketch from the downloads section if you want to play with it. There are lots of arduino cyclon sketches around, but most / all of them are 6 LED’s or less due to the hardware PWM limitation, so this one lets you have up to 14 LEDs without moving into shift register world. and the schematic is below for your information:
This is isn’t the finished product btw, juts a learning experience on the way. I have some high powered LED’s on the way from China, and some shift registers in the post, as the main issue with doing this in software is speed and I need some more speed for some additional functions 🙂