Lighting LEDs with PIC16f877a (Non-Sequential)

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Hi, I would like to ask on how to do non sequential patterns of lighting LEDs. What I mean is that for example I have 30 LEDs. They will all do running lights except that:

1. LED1 to LED10 flashes at 100ms delay. (Set 1)
2. LED11 to LED 20 flashes at 50ms delay. (Set 2)
3. LED21 to LED 30 flashes at 500us delay. (Set 3)
3. They all start together from the same time.

After successfully doing them, I would then add different PWM on each set.

What I only know is to light them sequentially but not non sequential. I wanted to do different speed and patterns from different parts of LEDs I'm designing. I hope you understand what I'm saying. Thank you in advance for your kind help. :)
 
Last edited:

Markd77

Joined Sep 7, 2009
2,806
Since you have conveniently chosen times which are multiples of each other, you can add a couple of counters so you do the 500us routine 100 times, then do your 50ms changes, another 100 of the 500us routines, then both the 100ms and 50ms changes, then repeat.
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Since you have conveniently chosen times which are multiples of each other, you can add a couple of counters so you do the 500us routine 100 times, then do your 50ms changes, another 100 of the 500us routines, then both the 100ms and 50ms changes, then repeat.
I find your statement not so clear. :( Can you help me please? Just few lines for basis and then I'll generate then my own.
 

Markd77

Joined Sep 7, 2009
2,806
This is one way of doing it, there are probably plenty of others.
Rich (BB code):
count1=100
count2=200
loop
   do something
   delay 500us
   count1 = count1 -1
   if count1 = 0 call every50ms
   count2 = count2 -1
   if count2 = 0 call every100ms
   goto loop

every50ms
   do something
   count1=100
   return

every100ms
   do something
   count2=200
   return
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Exactly what help do you need?


Does each set of LEDs all turn on at the same time or do individual LEDs wthin a set need to be controlled independently?
Yeah that's the idea! To control individual LEDs independently. Is it possible? All I know is synchronizing them.
 

spinnaker

Joined Oct 29, 2009
7,830
Yeah that's the idea! To control individual LEDs independently. Is it possible? All I know is synchronizing them.
Look Google "Charlieplexing". It is fairly complicated but a way to control a number of LEDs w/o and extra chips.

You could also use shift registers. With several hooked together you could control a bunch of LEDs w/o using too many pins of the PIC.
 

Thread Starter

lloydi12345

Joined Aug 15, 2010
103
Look Google "Charlieplexing". It is fairly complicated but a way to control a number of LEDs w/o and extra chips.

You could also use shift registers. With several hooked together you could control a bunch of LEDs w/o using too many pins of the PIC.
Wow never heard of charlieplexing in my entire life. That help me thanks.
 
Top