mirror of
https://github.com/eclipse/upm.git
synced 2025-07-01 17:31:13 +03:00
buzzer: C implementation; C++ wraps C
Signed-off-by: Jon Trulson <jtrulson@ics.com>
This commit is contained in:
@ -28,17 +28,17 @@ def main():
|
||||
# Create the buzzer object using GPIO pin 5
|
||||
buzzer = upmBuzzer.Buzzer(5)
|
||||
|
||||
chords = [upmBuzzer.DO, upmBuzzer.RE, upmBuzzer.MI, upmBuzzer.FA,
|
||||
upmBuzzer.SOL, upmBuzzer.LA, upmBuzzer.SI, upmBuzzer.DO,
|
||||
upmBuzzer.SI];
|
||||
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 one second
|
||||
print(buzzer.playSound(chords[chord_ind], 1000000))
|
||||
# play each note for a half second
|
||||
print(buzzer.playSound(chords[chord_ind], 500000))
|
||||
time.sleep(0.1)
|
||||
|
||||
print("exiting application")
|
||||
|
Reference in New Issue
Block a user