NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » Simple 'Dimming an LED example'
August 05, 2009 by mcai8sh4 |
Greetings fellow Nerdlings!! There has been some interest in how to change the brightness for an LED, the answer to this is PWM (either using the facilities built into the chip or emulating it). I just been talking to pH on the irc channel and decided to post a simple method (using PB1). The following code simple makes an LED go brighter and dimmer... forever (or until the battery runs out or your cat eats it!) If you read the code and check out the datasheet (essential reading folks - hard work, but essential), you should get the idea of how this works.
Code can also be found HERE NOTE : I only hacked this together from bits of the web/from the data sheet - I still don't fully understand it, so I probably won't be able to answer any technical questions, but hey I'll try!! Another method you could use is similar to the Valentines Heart tutorial - I haven't looked into this yet, but at some point I will, then I'll post a simple example (as above) for that method. |
---|---|
August 05, 2009 by pedroh96 |
I am AKA pH, :P |
August 19, 2009 by Nerdful_com |
Here is an example that dims all portb pins high to low with adjustable speeds.
// Hope this helps? Nerdful.com |
Please log in to post a reply.
Did you know that you can see each keypress on a computer keyboard on an oscilloscope? Learn more...
|