grove.py icon indicating copy to clipboard operation
grove.py copied to clipboard

grove/grove_pwm_buzzer.py missing

Open trothe opened this issue 3 years ago • 1 comments
trafficstars

But both the https://github.com/Seeed-Studio/grove.py/blob/master/setup.py script as well as various documentation (e.g. https://wiki.seeedstudio.com/Grove_Base_Hat_for_Raspberry_Pi/#usage) prominently mention grove_pwm_buzzer.

I cannot find grove/grove_pwm_buzzer.py it in the current master branch. Only a pull request from some time back. #55 Am I doing something wrong or has the file been deleted for some reason?

trothe avatar Jun 10 '22 17:06 trothe

Found it online somewhere

from __future__ import print_function

import time
from mraa import getGpioLookup
from upm import pyupm_buzzer as upmBuzzer

def main():

    print("Insert Grove-Buzzer to Grove-Base-Hat slot PWM[12 13 VCC GND]")
    
    # Grove Base Hat for Raspberry Pi
    #   PWM JST SLOT - PWM[12 13 VCC GND]
    pin = 12
    #
    # Create the buzzer object using RaspberryPi GPIO12
    mraa_pin = getGpioLookup("GPIO%d" % pin)
    buzzer = upmBuzzer.Buzzer(mraa_pin)
                                        
    chords = [upmBuzzer.BUZZER_DO, 
            upmBuzzer.BUZZER_RE, 
            upmBuzzer.BUZZER_MI,
            upmBuzzer.BUZZER_FA, 
            upmBuzzer.BUZZER_SOL, 
            upmBuzzer.BUZZER_LA,
            upmBuzzer.BUZZER_SI];
                                         
    # Print sensor name
    print(buzzer.name())
                                                     
    # Play sound (DO, RE, MI, etc.), pausing for 0.1 seconds between notes
    for chord_ind in range (0,7):
        # play each note for a half second
        print(buzzer.playSound(chords[chord_ind], 500000))
        time.sleep(0.1)
                                                                                          
    print("exiting application")
                                                                                               
    # Delete the buzzer object
    del buzzer
                                                                                                        
if __name__ == '__main__':
    main()                                                                                                     

Khaos66 avatar Nov 03 '22 09:11 Khaos66