need help! to beginner


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    Join Date
    Apr 2009
    Posts
    29

    Unhappy need help! to beginner

    Hello I want to write code to imitate siren sounds li Air horn pulsar wait yelp .
    i have used freqout to make first 2. but others do not stop when i unpress button lease advise what to do?

    If PORTB.7 =0 THEN
    Freqout PORTB.0,4,1700 ;------------- air horn
    Freqout PORTB.0,4,850
    Freqout PORTB.0,4,1250
    Freqout PORTB.0,4,425
    Endif
    If PORTB.6 =0 THEN
    Freqout PORTB.0,8,366 ;------------- pulsar
    Freqout PORTB.0,8,483
    Freqout PORTB.0,8,591
    Freqout PORTB.0,8,664
    Freqout PORTB.0,8,760
    Freqout PORTB.0,8,886
    Freqout PORTB.0,8,967
    Freqout PORTB.0,8,1070
    Freqout PORTB.0,8,1182
    Freqout PORTB.0,8,1330
    endif

    for this too freqout is ok because they are short what to do with longer ones?

  2. #2
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Well, post your whole code, and schematic, we could help further.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  3. #3
    Join Date
    Apr 2009
    Posts
    29


    Did you find this post helpful? Yes | No

    Default I can not stop running of programm when on some point the button is unpressed

    TRISB = %11111111
    OPTION_REG.7 = 0


    loop:

    If PORTB.7 =0 THEN
    Freqout PORTB.0,4,1700 ;------------- air horn
    Freqout PORTB.0,4,850
    Freqout PORTB.0,4,1250
    Freqout PORTB.0,4,425
    Endif




    If PORTB.6 = 0 Then
    Freqout PORTB.0,8,366 ;------------- pulsar
    Freqout PORTB.0,8,483 ;
    Freqout PORTB.0,8,591
    Freqout PORTB.0,8,664
    Freqout PORTB.0,8,760
    Freqout PORTB.0,8,886
    Freqout PORTB.0,8,967
    Freqout PORTB.0,8,1070
    Freqout PORTB.0,8,1182
    Freqout PORTB.0,8,1330
    Endif

    If PORTB.5 = 0 Then
    Freqout PORTB.0,10,366 ;------------- yelp
    Freqout PORTB.0,10,483
    Freqout PORTB.0,10,591
    Freqout PORTB.0,10,664
    Freqout PORTB.0,10,760
    Freqout PORTB.0,10,886
    Freqout PORTB.0,10,967
    Freqout PORTB.0,10,1070
    Freqout PORTB.0,10,1182
    Freqout PORTB.0,10,1330 ---------- how to check? just to say if in this point button is unpressed and stop running
    Freqout PORTB.0,10,1182
    Freqout PORTB.0,10,1070
    Freqout PORTB.0,10,967
    Freqout PORTB.0,10,886
    Freqout PORTB.0,10,760
    Freqout PORTB.0,10,664
    Freqout PORTB.0,10,591
    Freqout PORTB.0,10,483
    Freqout PORTB.0,10,366
    endif


    goto loop
    end
    Attached Images Attached Images  

  4. #4
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    One of the several way to do it, untested though
    Code:
    Frequency var word
    CounterA    var Byte
    
    If PORTB.5 = 0 Then
            CounterA = 0
    Yelp:        
            Lookup2 CounterA,[366,483,591,664,760,886,967,1070,1182,1330,1182,1070,967,886,_
                            760,664,591,483,366],Frequency    
            Freqout PORTB.0,10,Frequency
            if PORTB.5=0 then
                CounterA = CounterA + 1
                if Countera < 19 then goto Yelp
                endif
            endif
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  5. #5
    Join Date
    Apr 2009
    Posts
    29


    Did you find this post helpful? Yes | No

    Thumbs up I will try it

    thank you wery much

  6. #6
    Join Date
    Apr 2009
    Posts
    29


    Did you find this post helpful? Yes | No

    Default More info needed

    Can anybody show different way of doing the same???

Similar Threads

  1. Replies: 17
    Last Post: - 12th April 2014, 02:17
  2. pic24 beginner
    By robertpeach in forum General
    Replies: 23
    Last Post: - 13th August 2009, 11:57
  3. Replies: 10
    Last Post: - 2nd May 2009, 07:42
  4. Beginner trying to use arrays
    By captain in forum mel PIC BASIC Pro
    Replies: 8
    Last Post: - 3rd November 2007, 07:20
  5. Pic ID Error please help (beginner)
    By ninja in forum General
    Replies: 4
    Last Post: - 11th August 2005, 17:54

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