Newbie project, please comment


New Member

I'm sure this is trivial to you experts. But this is my first project, so I'd appreciate if someone could have a quick look at the my code and circuitry to see if I'm on the right track.

All I want is to control the intensity of a high power LED (yes, another bike light project!). Please let me know if there's something I've overlooked.

I'm aware of a small bug (noted in the code), and don't know if I need a capacitor to stabilise the voltage to the Picaxe (see circuit). But there may of course be no end of other mistakes.


'Luxeon Tri-Emitter Dimmer (Bike Light)
'File name:Luxeon rebel controller v0.0.1b.bas
'Author: Ulrik H. Gade
'Heavily inspired by (thanks Tom!)
'Absolutely no rights reserved

' pins
symbol led_pin = 2
symbol modeButton = pin4

' variables
symbol mode = b0
symbol led_duty = w5

' constants
symbol MAX_MODE = b1

' initialize
mode = 0
high led_pin
poke $8F,%01010000 ' Reduce clock speed to 2 MHz by poking the OSCCON register (else PWM freq too high + save power)

if modeButton = 1 then
if mode < MAX_MODE then
mode = mode + 1 'Minor bug: led_pin goes high in debugger at this point (why?)
mode = 1
gosub changeMode
pause 200
goto main

'BuckPuck LED driver requires inverse control signal, i.e. shorter duty cycle => brighter light
select mode
case 1 ' 25%
led_duty = 750
gosub setPWM
case 2 ' 50%
led_duty = 500
gosub setPWM
case 3 ' 75%
led_duty = 250
gosub setPWM
case 4 ' 100%
pwmout led_pin off
low led_pin
case 5 ' off
pwmout led_pin off
high led_pin

pwmout led_pin, 249, led_duty ' PWM base frequency 2 kHz
poke $12, $06 'reduce PWM frequency by 1/16 to 125 Hz



Senior Member
I have no experience driving high power LEDs, so I can't comment on your code. However, I did find the email included below in my inbox a few days ago. It might be of interest to you.




From: National Semiconductor <>
dated Oct 31, 2007


Driving High-Power LEDs Without Getting Burned - Part 1

Co-Hosted by Bob Pease & Dr. Howard Johnson

Tune in Today!


Widely used in trucking and automotive lighting assembles, high-power LEDs are being designed into lighting applications for industry, business, and home. Government regulations, including ENERGY STAR in the U.S., plus simple economics are driving the adoption of LED lighting. But because high-power LEDs operate and are used differently from CCFL and incandescent lights, myths and confusion abound about how to best design with these solid-state lighting elements.

In Part 1 of this two-part series, Dr. Howard Johnson joins National's Bob Pease and Applications Engineer Chris Richardson to talk with special guests Patrick Durand (Future Lighting Solutions) and Pat Goodman (Philips Lumileds) about managing the color, brightness, and lifetime of high-power LEDs.

In this show:

* A tasty demonstration of why to use LED lighting in a chocolate shop
* #1 myth about LEDs is busted
* Where and why to use LED lighting
* How to design for greatest LED lifetime
* 2 ways of making "white" light, plus 3 types of "white"

Duration: 57 mins

Special Guests:
Patrick Durand - Future Lighting Solutions
Pat Goodman - Philips Lumileds Lighting Co.
Chris Richardson - National


New Member
Very &quot;illuminating&quot;...

...if you'll forgive the pun! Though the as yet to be published feature on drivers will probably be more to the point.