Delayed output 10 secs


Closed Thread
Results 1 to 38 of 38

Hybrid View

  1. #1
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    here is the rest...
    Code:
          
    Channel1:
        pause 25                                  ; debounce
        if sw1 = 0 then
            if led1 = 0 or swstat = 1 then
                if led1 = 0 then sound pz,[123,10]: high led1
                pause 300
                swstat = 1
                l=l+1
                if l => 5 then 
                    for i = 1 to 11: toggle led1: sound pz,[123,10]: pause 50: next i
                    goto Bprog1
                else
                    goto Channel1
                endif
            else
                low led1: low tr1: sound pz,[123,10]
                pause 100
            while sw1 = 0: wend
            endif
        endif
        swstat = 0   
        goto main
    
    Channel2:
        pause 25                                  ; debounce
        if sw2 = 0 then
            if led2 = 0 or swstat = 1 then
                if led2 = 0 then sound pz,[123,10]: high led2
                pause 300
                swstat = 1
                l=l+1
                if l => 5 then 
                    for i = 1 to 11: toggle led2: sound pz,[123,10]: pause 50: next i
                    goto Bprog2
                else
                    goto Channel2
                endif
            else
                low led2: low tr2: sound pz,[123,10]
                pause 100
            while sw2 = 0: wend
            endif
        endif
        swstat = 0   
        goto main
    
    Channel3:
        pause 25                                  ; debounce
        if sw3 = 0 then
            if led3 = 0 or swstat = 1 then
                if led3 = 0 then sound pz,[123,10]: high led3
                pause 300
                swstat = 1
                l=l+1
                if l => 5 then 
                    for i = 1 to 11: toggle led3: sound pz,[123,10]: pause 50: next i
                    goto Bprog3
                else
                    goto Channel3
                endif
            else
                low led3: low tr3: sound pz,[123,10]
                pause 100
            while sw3 = 0: wend
            endif
        endif
        swstat = 0   
        goto main
    
    Channel4:
        pause 25                                  ; debounce
        if sw4 = 0 then
            if led4 = 0 or swstat = 1 then
                if led4 = 0 then sound pz,[123,10]: high led4
                pause 300
                swstat = 1
                l=l+1
                if l => 5 then 
                    for i = 1 to 11: toggle led4: sound pz,[123,10]: pause 50: next i
                    goto Bprog4
                else
                    goto Channel4
                endif
            else
                low led4: low tr4: sound pz,[123,10]
                pause 100
            while sw4 = 0: wend
            endif
        endif
        swstat = 0   
        goto main
    
    Channel5:
        pause 25                                  ; debounce
        if sw5 = 0 then
            if led5 = 0 or swstat = 1 then
                if led5 = 0 then sound pz,[123,10]: high led5
                pause 300
                swstat = 1
                l=l+1
                if l => 5 then 
                    for i = 1 to 11: toggle led5: sound pz,[123,10]: pause 50: next i
                    goto Bprog5
                else
                    goto Channel5
                endif
            else
                low led5: low tr5: sound pz,[123,10]
                pause 100
            while sw5 = 0: wend
            endif
        endif
        swstat = 0   
        goto main
        
    Channel6:
        pause 25                                  ; debounce
        if sw6 = 0 then
            if led6 = 0 or swstat = 1 then
                if led6 = 0 then sound pz,[123,10]: high led6
                pause 300
                swstat = 1
                l=l+1
                if l => 5 then 
                    for i = 1 to 11: toggle led6: sound pz,[123,10]: pause 50: next i
                    goto Bprog6
                else
                    goto Channel6
                endif
            else
                low led6: low tr6: sound pz,[123,10]
                pause 100
            while sw6 = 0: wend
            endif
        endif
        swstat = 0   
        goto main
    
    Bprog1:
        WHILE !T0IF : WEND
        TMR0 = 225
        T0IF = 0
    
        IF Counters(0) > 0 THEN Counters(0) = Counters(0) - 1  
        IF Counters(0) = 0 THEN
            if y = 0 then y = 3 
            if y > 12 then y = 12 
            write 0,y
            for I = 1 to y: high led1:sound pz,[123,10]:pause 50:low led1: pause 50: next i
            goto main
        endif
        if sw1 = 0 then
            pause 25                        ;debouce
            if sw1 = 0 then
                Counters[0] = DelayTime
                high led1: sound pz,[123,10]: pause 25
                y = y + 1: low led1
                Counters[0] = DelayTime
            endif
        endif
        goto bprog1
    
    Bprog2:
        WHILE !T0IF : WEND
        TMR0 = 225
        T0IF = 0
    
        IF Counters(1) > 0 THEN Counters(1) = Counters(1) - 1  
        IF Counters(1) = 0 THEN
            if y = 0 then y = 3 
            if y > 12 then y = 12 
            write 1,y
            for I = 1 to y: high led2:sound pz,[123,10]:pause 50:low led2: pause 50: next i
            goto main
        endif
        if sw2 = 0 then
            pause 25                        ;debouce
            if sw2 = 0 then
                Counters[1] = DelayTime
                high led2: sound pz,[123,10]: pause 25
                y = y + 1: low led2
                Counters[1] = DelayTime
            endif
        endif
        goto bprog2
    
    Bprog3:
        WHILE !T0IF : WEND
        TMR0 = 225
        T0IF = 0
    
        IF Counters(2) > 0 THEN Counters(2) = Counters(2) - 1  
        IF Counters(2) = 0 THEN
            if y = 0 then y=3
            if y > 12 then y = 12 
            write 2,chargetime(2)
            for I = 1 to y: high led3:sound pz,[123,10]:pause 50:low led3: pause 50: next i
            goto main
        endif
        if sw3 = 0 then
            pause 25                        ;debouce
            if sw3 = 0 then
                Counters[2] = DelayTime
                high led3: sound pz,[123,10]: pause 25
                y = y + 1: low led3
                Counters[2] = DelayTime
            endif
        endif
        goto bprog3
    
    Bprog4:
        WHILE !T0IF : WEND
        TMR0 = 225
        T0IF = 0
    
        IF Counters(3) > 0 THEN Counters(3) = Counters(3) - 1  
        IF Counters(3) = 0 THEN
            if y = 0 then y = 3 
            if y > 12 then y = 12 
            write 3,y
            for I = 1 to y: high led4:sound pz,[123,10]:pause 50:low led4: pause 50: next i
            goto main
        endif
        if sw4 = 0 then
            pause 25                        ;debouce
            if sw4 = 0 then
                Counters[3] = DelayTime
                high led4: sound pz,[123,10]: pause 25
                y = y + 1: low led4
                Counters[3] = DelayTime
            endif
        endif
        goto bprog4
        
    Bprog5:
        WHILE !T0IF : WEND
        TMR0 = 225
        T0IF = 0
    
        IF Counters(4) > 0 THEN Counters(4) = Counters(4) - 1  
        IF Counters(4) = 0 THEN
            if y = 0 then y = 3 
            if y > 12 then y = 12 
            write 4,y
            for I = 1 to y: high led5:sound pz,[123,10]:pause 50:low led5: pause 50: next i
            goto main
        endif
        if sw5 = 0 then
            pause 25                        ;debouce
            if sw5 = 0 then
                Counters[4] = DelayTime
                high led5: sound pz,[123,10]: pause 25
                y = y + 1: low led5
                Counters[4] = DelayTime
            endif
        endif
        goto bprog5
    
    Bprog6:
        WHILE !T0IF : WEND
        TMR0 = 225
        T0IF = 0
    
        IF Counters(5) > 0 THEN Counters(5) = Counters(5) - 1  
        IF Counters(5) = 0 THEN
            if y = 0 then y = 3 
            if y > 12 then y = 12 
            write 5,y
            for I = 1 to y: high led6:sound pz,[123,10]:pause 50:low led6: pause 50: next i
            goto main
        endif
        if sw6 = 0 then
            pause 25                        ;debouce
            if sw6 = 0 then
                Counters[5] = DelayTime
                high led6: sound pz,[123,10]: pause 25
                y = y + 1: low led6
                Counters[5] = DelayTime
            endif
        endif
        goto bprog6
        
    StartCharge1:
        high TR1:
        return
    
    StartCharge2:
        high TR2:
        return
    
    StartCharge3:
        high TR3:
        return
    
    StartCharge4:
        high TR4:
        return
        
    StartCharge5:
        high TR5:
        return
    
    StartCharge6:
        high TR6:
        return

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Like you said, you've only had PBP a couple weeks ...
    Laughing would only be Rude.

    Thanks for the code!
    I think I can do something with it.

    But first I'd like to point out the WORST Basic statement ever devised.
    Code:
    PAUSE xx
    It turns an amazingly fast processor into a "thumb twiddling idiot".
    Spending most of it's time doing nothing.
    If I were that chips Boss, I'd fire it.

    Granted, there are a few instances when PAUSE is required. But if at all possible, avoid PAUSE at all costs.

    Working on it ....
    DT

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Like you said, you've only had PBP a couple weeks ...
    Laughing would only be Rude.

    Thanks for the code!
    I think I can do something with it.

    But first I'd like to point out the WORST Basic statement ever devised.
    Code:
    PAUSE xx
    It turns an amazingly fast processor into a "thumb twiddling idiot".
    Spending most of it's time doing nothing.
    If I were that chips Boss, I'd fire it.

    Granted, there are a few instances when PAUSE is required. But if at all possible, avoid PAUSE at all costs.

    Working on it ....
    I guess I took his 720 min out of context, pretty much thought it was a stand alone app, please allow me to take For Next, Ugh Pause, and pull up my pants , . . . "thumb twiddling idiot "!, careful Darrel, that's getting pretty close to home . . . , But Darrel <B> IS ,</b> right.
    If you do not believe in MAGIC, Consider how currency has value simply by printing it, and is then traded for real assets.
    .
    Gold is the money of kings, silver is the money of gentlemen, barter is the money of peasants - but debt is the money of slaves
    .
    There simply is no "Happy Spam" If you do it you will disappear from this forum.

  4. #4
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S. View Post
    But Darrel <B> IS ,</b> right.
    I got this lady ... could you repeat that to her?

    Mike,

    Are you stuck with the SOUND command, or do you just want a beep from the piezo?
    I'm gonna have problems with PBP's SOUND command and interrupts.
    <br>
    DT

  5. #5
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    The beep doesn't have to come from the sound command, I didn't know it could be generated another way! as long as it goes beep when LEDx changes state is good.

    I will learn from this project but I have a couple of other projects I will impress you with!

    Thank you soooooo much for your help.

    Mike

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Yowwwsaaaa!

    I saw something interesting floating thru the forum's waters, and I grabbed at it.
    Ummm, excuse me ... can I give it back?
    It looked like a piece of Tuna, I didn't know there was a Hook in it!

    Oh OK, I guess not.

    So many timers and conditions and beeps,
    I'm just going to gnaw on this a little more ...
    see if I can't work that hook out of my cheek before I hit surface.
    <br>
    DT

  7. #7
    Join Date
    May 2009
    Location
    Montreal, QC, Canada
    Posts
    118


    Did you find this post helpful? Yes | No

    Default

    I was kind of fiddling with part of your timer code and part of what I had and I was able to get all the timings, highs and lows at the right place but the beep with the sound command is really lowsy, instead of beep it goes brererererep!
    Of course If I had an scope I might see other strange things!

Similar Threads

  1. How to drive the Vinculum VDIP1 in UART mode
    By BrianT in forum Code Examples
    Replies: 41
    Last Post: - 23rd May 2013, 13:34
  2. USB-FTDI[UM232R] with PIC16f877a
    By bjox in forum USB
    Replies: 1
    Last Post: - 23rd February 2008, 23:40
  3. Serious Serial Situation Setbacks...
    By Dansdog in forum mel PIC BASIC Pro
    Replies: 5
    Last Post: - 7th February 2007, 04:46
  4. Serial Output 10 Bits
    By GEEZER in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 17th May 2005, 03:14
  5. Using 4 input to control 10 output
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th November 2004, 13:08

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts