Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

need a 4 minute delay

Status
Not open for further replies.

MrDEB

Well-Known Member
I have Time_delay declared as a LONGWORD
[ICODE
//TURN ON THE RED LED STRIPS (100 ON TOP OF CAKE)
Red_Candle_STRIPS = 1 //turn on the red 100 on top of cake
time_delay = time_delay + 1
until
time_delay = 240000 // 4 miniutes

][/ICODE]
Not sure if this is a good method to have other code running until Time_delay = 240000
 
Enjoy your "non-complex" spaghetti code. Get a side of garlic bread with it.
 
Last edited:
thanks, will be cutting, and soldering a bunch of wires today.
I'm afraid to ask, but in light of your proposed connections in post 36, how do you have the LEDs connected now?

They should have a common +12V line (to LED +V) and an individual control connection (to LED "GND") back to the PCB. The LED turns on when the MOSFET turns on and connects the LED GND to the PCB 12V GND..
 
When I connected all the LED strips I made the ground common and the 12v+ for each letter to the PCB.

I have to cut the ground wire connections to each letter, then make the 12v+ to each letter a common connection and route the grounds from each letter to their respective connection on the PCB.
Yesterday spent several hours preparing the 2- 9 pin Molex connectors. One for 12volt and the other for the 5volt.
Using these I can remove the board without having to desolder anything hopefully.
So post# 42 is correct. Give tumbleweed a cookie.
 
Regarding my sequencer program posted above – the program needs a few minor tweaks and improvements which I'll post soon.

Here's a video showing adding LEDs one at a time until they are all illuminated, then turning them off. I believe the dropbox link will work ok.

For anyone trying out the program before I post a revised version.... I managed to convince myself that my on-off logic in the UpdateState subroutine was backwards and I changed it. Nope, it was correct as originally written.... So in the posted version, the on/off logic should be swapped.

As it should be:

Code:
    'Item 1
    If ItemIsOn(1) = true Then
            'do what it takes to turn off
            LED1 = LEDoff
        Else
            'do what it takes to turn on
            LED1 = LEDon
    End If
 
I've refined my Sequence Timer program from post #39, and straighten out some of my logic. This program allows displaying sequences of LEDs in any number of formats:

> Building sequence - first LED on, delay, second LED on, delay, third LED on, delay, etc.

> Chasers and marque displays - LEDs turn on and off in turn, with or without overlap

> Alternating LED patterns

The patterns are set up by setting the ON interval, OFF interval and DELAY interval for each LED.

A couple examples are shown here.

BUILD SEQUENCE


Build Sequence Video


Code:
Sub Initialize()    'set the parameters for each item here: on interval, off 
                    'interval and offset interval
                    'set up the timing intervals here - 3 parameters per item
    'item 1
    ItemStartDelay(1)= 0  'offset interval
    ItemOnInterval(1)= 10 'on interval
    ItemOffInterval(1)= 2 'off interval
    ItemTriggerTicks(1) = ItemStartDelay(1) + ItemOnInterval(1)
   
    'item 2
    ItemStartDelay(2)= 2 'offset interval
    ItemOnInterval(2)= 8 'on interval
    ItemOffInterval(2)= 4 'off interval
    ItemTriggerTicks(2) = ItemStartDelay(2) + ItemOnInterval(2)

    'item 3
    ItemStartDelay(3)= 4 'offset interval
    ItemOnInterval(3)= 6 'on interval
    ItemOffInterval(3)= 6 'off interval
    ItemTriggerTicks(3) = ItemStartDelay(3) + ItemOnInterval(3)

    'item 4
    ItemStartDelay(4)= 6 'offset interval
    ItemOnInterval(4)= 4 'on interval
    ItemOffInterval(4)= 8 'off interval
    ItemTriggerTicks(4) = ItemStartDelay(4) + ItemOnInterval(4)

    'repeat for all items. 
   
    For I = 1 To NumberOfItems
        ItemIsOn(I) = false
    Next
End Sub


MARQUE/CHASER

Marque video

Code:
Sub Initialize()    'set the parameters for each item here: on interval, off 
                    'interval and offset interval
                    'set up the timing intervals here - 3 parameters per item
    'item 1
    ItemStartDelay(1)= 0 'offset interval
    ItemOnInterval(1)= 10 'on interval
    ItemOffInterval(1)= 20 'off interval
    ItemTriggerTicks(1) = ItemStartDelay(1) + ItemOnInterval(1)
   
    'item 2
    ItemStartDelay(2)= 9 'offset interval
    ItemOnInterval(2)= 10 'on interval
    ItemOffInterval(2)= 20 'off interval
    ItemTriggerTicks(2) = ItemStartDelay(2) + ItemOnInterval(2)

    'item 3
    ItemStartDelay(3)= 18 'offset interval
    ItemOnInterval(3)=  10'on interval
    ItemOffInterval(3)= 20 'off interval
    ItemTriggerTicks(3) = ItemStartDelay(3) + ItemOnInterval(3)

    'item 4
    ItemStartDelay(4)= 25 'offset interval
    ItemOnInterval(4)= 10 'on interval
    ItemOffInterval(4)= 20 'off interval
    ItemTriggerTicks(4) = ItemStartDelay(4) + ItemOnInterval(4)

    'repeat for all items. 
   
    For I = 1 To NumberOfItems
        ItemIsOn(I) = false
    Next
End Sub
 
It's not for you. I did it for myself. People with a better understanding of coding will appreciate its simplicity.
 
Something I should have explained....

In my above examples, four LEDs are marching along in patterns that take about 30 seconds (depending on the timer interupt time, I used 100mS, so the sequence runs at 10x speed). What I didn't explain is that more items (LEDs) can be added that "do there own thing" independently of those four LEDs.

Say we add item 5 with an ON interval of 1, an OFF interval of 157, and an offset of 13. This LED will flash on for 1 second about every two and a half minutes, while the first 4 continue to march along.

Add item 6 with an on interval of 1, an off interval of 171, and an offset of 23. This LED will flash briefly, sometimes matching up with LED 5, sometimes not.

Add more items with similar "random" times and you have a mob of twinkling stars. While the original four LEDs continue dutifully marching along. With ZERO delay statements, everybody does their own thing.

BUT, the times don't have to be fixed. For twinkling items, the ON and OFF times could be varied every time through the loop with the random function without any changes to ANY of the subroutines.

*shrug* I don't care if MrDEB uses this or not. Again, I did it as an exercise for myself.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top