> -----Original Message----- > From: Pic Dude [SMTP:picdude@AVN-TECH.COM] > Sent: Wednesday, February 27, 2002 8:10 AM > To: PICLIST@MITVMA.MIT.EDU > Subject: [PIC]: LED brightness control thru PIC... > > I would like to control the brightness of some LEDs (directly attached to > a port on a PIC) thru code. Each LED would be at full bright or dim -- > just > 2 intensities. Here's what I thought... > > Assume as some point in the code, I want to set the output to > 'ooBoDDBo' where 'o' is Off, 'B' is Bright, and 'D' is Dim. > > Let V1 = value of port for dim LED's. In this case V1 = '00001100' > Let V2 = value of port for bright LED's. In this case V2 = '00100010' > > Then set V3 1 = V1 OR V2 = 00101110' > > Now in my code, every time I come around in the main loop, I would > alternate the output between V1 and V3. Bright LEDs would get set > all the time (both times), and dim LED's would get set only on alternate > cycles -- sort of like a pulse-width dimmer. > > Perhaps I may need to have 3 cycles with V1, V1, V3 depending on > relative brightness level, etc. > > Is this reasonable? Is there an easier/better way to do this? I'll be > using a 16F84 or 16F872 for this. > > Thanks, > -Neil. > > Neil, Check the recent thread "Ultra fast low res PWM". There are several code examples for minimal software PWM routines that take only a few cycles. Regards Mike -- http://www.piclist.com hint: The list server can filter out subtopics (like ads or off topics) for you. See http://www.piclist.com/#topics