General Question about PICs

dpbarry

New Member
Hi Folks..

Just starting out with PICs but was wondering if someone could answer a general question regarding PIC's and LED's

Is it possible to program a PIC to flash LED's with differencet patterns?

By that I mean, Whilst the PIC code is flashing one LED sequence on an output, can it flash a different sequence on another output but not once sequence after the other.

Hope that makes sense.

I have two project that I hope to work on. One is a Lighhouse flashing circuit that I dabbled with a while back but with work commitments, never got to grips with it. Work has now backed off so I am trying to fit into the electronic scene again.

Another projects is flashing lights on a radio controlled plane - i.e Landing lights. Can I use a pic to switch on two leds and switch on a third led that flashes a particular sequence.

I'm off to read the manuals but would be interested to hear peoples comments on the above - especially about getting pic's to 'Multitask'

Regards

Declan
 

BeanieBots

Moderator
Yes you can, but the PICAXE cannot multitask, so it is up to you to 'thread' your sequences together. One simple approach is to set up a simple loop which goes round in a set amount of time, then within that loop, decide what needs to be on and what needs to be off.

As soon as I can get my scanner working, I'm going to publish yet another RGB led fader.
It only uses an 08M but has three pots to determine the brightness of each colour, has a switch to determine a pattern sequence which can have it's speed varied and have various selectable pattern sequences. You could probabaly get some ideas from that once I've posted it.

For the rest of you clever clogs out there, any guesses what the trick is?
No extra silcon, just an 08M, a bunch of resistors plus 3 pots and a switch.
 
Last edited:

Andrew Cowan

Senior Member
For the rest of you clever clogs out there, any guesses what the trick is?
No extra silcon, just an 08M, a bunch of resistors plus 3 pots and a switch.
I did that using one pot, and three switches (on a 14M). I'm guessing readadc then pulsout that value, plus a pause (if needed)

Code:
read pots
pulsout red (0-255)
pulsout green (0-255)
pulsout blue (0-255)
w0=765-red-blue-green
pulsout pause (w0)
Am I on the right lines?

A
 

inglewoodpete

Senior Member
To return to dpbarry's original request, I would use a number of count-down timers in a timed loop.

The overall loop would execute continually, an important part of the loop would be a delay (lets say a 100mS pause statement). A number of decrementing registers (I suggest byte regs) would be initialised, one 'timer' per output LED, to appropriate values: larger numbers for longer flash periods and smaller for short periods.

Each register would be decremented once on each loop. As each register reaches 0, the appropriate output would be switched on or off, then the counter value would be reset.

For varying mark/space ratios of each LED you could test for a certain value and switch the LED on, then switch the LED off at 0. Eg for a flash cylce period of 2 seconds, the register would be initialised to 20 (assuming a 100mS pause at the end of each loop). The output could be switch 'on' at 15 and 'off' at 0. Multiple flashes could be arranged for each output using this method.
 
Top