B4R Library rEasyBuzzer

Discussion in 'B4R Libraries' started by Johan Schoeman, Jun 22, 2019.

  1. Johan Schoeman

    Johan Schoeman Expert Licensed User

    A B4R wrap for this Github project. The attached B4R project plays the very famous Nokia Tune making use of a passive buzzer. Explore the other methods exposed by the library...

    Sure you will know what to do with the attached lib files. B4R project also attached.

    Enable rEasyBuzzer in the libs tab of the B4R IDE.

    Nokia Tune frequency and timing comes from here

    EazyBuzzer_bb.png

    Sample code to play the Nokia Tune:

    Code:
    #Region Project Attributes
        
    #AutoFlushLogs: True
        
    #CheckArrayBounds: True
        
    #StackBufferSize: 300
    #End Region

    Sub Process_Globals
        
    'These global variables will be declared once when the application starts.
        'Public variables can be accessed from all modules.
        Public Serial1 As Serial
        
    Dim eb As EasyBuzzer
        
    Dim t As Timer
        
    End Sub

    Private Sub AppStart
        Serial1.Initialize(
    115200)
        
    Log("AppStart")
        t.Initialize(
    "t_tick"10)
        eb.initialize
        eb.Pin = 
    5
    '    eb.OnDuration = 500                           'On Duration in ms
    '    eb.OffDuration = 500                          'Off Duration in ms
    '    eb.beepFreqAndNoOfTimes(1000, 10)             'This call uses OnDuration and OffDuration
    '   eb.singleBeep(5000, 2000)                     'Make a single beep at Freq = 5000 Hz and Duration = 2000 ms

    '    eb.beepSequence(1500, 200, 100, 7, 2000, 3)

        Delay(
    500)

        AddLooper(
    "myLopper")
        
        t.Enabled = 
    True
        
    '    eb.beepContinuously(1500)
        
    End Sub

    Sub t_tick
        
        eb.update                                     
    'call this frequently to update the buzzer
        
    End Sub

    Sub myLopper
        
        
    'play the famous Nokia Tune
        eb.singleBeep(1319,133)
        Delay(
    143)
        eb.singleBeep(
    1175,133)
        Delay(
    143)
        eb.singleBeep(
    740,267)
        Delay(
    277)
        eb.singleBeep(
    831,267)
        Delay(
    277)
        eb.singleBeep(
    1109,133)
        Delay(
    143)
        eb.singleBeep(
    988,133)
        Delay(
    143)
        eb.singleBeep(
    587,267)
        Delay(
    277)
        eb.singleBeep(
    659,267)
        Delay(
    277)
        eb.singleBeep(
    988,133)
        Delay(
    143)
        eb.singleBeep(
    880,133)
        Delay(
    143)
        eb.singleBeep(
    554,267)
        Delay(
    277)
        eb.singleBeep(
    659,267)
        Delay(
    277)
        eb.singleBeep(
    880,533)
        Delay(
    1000)
        eb.stopBeep
        Delay(
    2000)
        
    End Sub
     

    Attached Files:

    Mostez, Mashiane, Erel and 2 others like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice