PWM is pulse width modulation. This means that the signal goes high and low, and the high pulses are sometimes longer than low pulses and vice versa. If the high pulses are longer than the low pulses (assuming your LED is on when the pin is high) then the LED is brighter. If the low pulses are longer than the high pulses then they LED is dimmer. A very simple and fairly easy way to make the LED dim in and out is to do something like this (fake code, haven't tested, let me know if you need tested code): x=0; y=0; :label1 Turn the LED on. y=0 Loop here and count y up until y = x; (call delay each count up) Turn LED off. y=255; Loop here and count y down until y = x; (call delay each count up) x=x+1 goto label1 :delay z = 0 count up until z = 255 return When x is small, the LED will be dim, because it will be off for longer than it is on. When x is large it will be bright because it is on for longer than it is off. You can comment out the "x=x+1" and just set x at the start to set a particular brightness. If the PIC is running at 8 MHz, then the LED will go from off to on over about 8 to 10 seconds and then restart at off. I hope this makes sense - if not, ask more questions! -Adam On 1/23/07, Balthasar Indermuehle wrote: > Hi all, > > I just received my PicKit2 today featuring a 16F917, and despite never > having programmed a PIC before I made rapid progress switching LED's on and > off (I've been practising with a simulator for the past few days). I then > searched the archives for information on how to fade in/out those LED's, but > unfortunately I do not understand how that is supposed to work. > > Can someone explain to me in hardware newbie terms, how I can use the pulse > width modulation method on the LED's connected to PORTD (TRISD)? Some sample > code would be of great help, too. > > Thanks! > > - Balt > > -- > http://www.piclist.com PIC/SX FAQ & list archive > View/change your membership options at > http://mailman.mit.edu/mailman/listinfo/piclist > -- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Moving in southeast Michigan? Buy my house: http://ubasics.com/house/ Interested in electronics? Check out the projects at http://ubasics.com Building your own house? Check out http://ubasics.com/home/ -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist