buzzer tutorial ?


is there any tutorial to use a buzzer, like this ?


Mmm… I guess you can use the rtttl library example by changing the pwm pin to whatever pin you will connect that I/O marked pin on the buzzer…but let’s ask @Daniele to be sure.

To play sounds, just set a correct PWM wave with pwm.write(). For  example, an A note is 440Hz, so, 440 “waves”  in a second, so each waves lasts for 1/440 seconds. 

This is the code to generate a wave given in Hz:

def play(pin,hz):
    freq = 1000000//hz


I have amplified the sound with pam8403 IC because the buzzer was very low.

Now, I would like to make a melody…How I to do ?


the code that I written is:

import pwm

def play(pin,hz):
    freq = 1000000//hz

# the pin where the buzzer is attached to
buzzerpin = D8.PWM

pinMode(buzzerpin,OUTPUT) #set buzzerpin to output mode


<br><br>but so I play one note for infinity....<br><br>


Install the rtttl library from the package manager and pass it a string representing the melody.

Otherwise, it is just a matter of calling play, sleeping for the length of the note, call play again, etc…here is a table with all note frequencies.


I tried to install rtttl library, but I see an error:

"Error: something wrong: Can’t download package"

why ?


Hi cman, I am sorry for this late response, have you solved anyway?
I tried downloading the package and everything looks ok.
Let me know


I try now but I have the same problem:

“Error: something wrong: Can’t download package”


Which Operating System are you using? And which version of the IDE and vpm (Help->About core.zerynth.ide, core.zerynth.vpm)?


I’m using Ubuntu 14.04 64 bit.
IDE version:
- core.zerynth.ide r1.0.3
- core.zerynth.vpm r1.0.2


Hi cman,
it could be a git issue, try:

~/.zerynth/env/sys/git/git --help
<p>to see if everything is ok.</p><p>Anyway you can manually clone RTTTL Library directly from github: <br></p><br><br>


about git:

~/.zerynth/env/sys/git/git --help
uso: git [--version] [--help] [-C ] [-c name=value]
           [--exec-path[=]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=] [--work-tree=] [--namespace=]

I comandi git usati più di frequente sono:
   add        Aggiunge il contenuto del file a index
   bisect     Cerca mediante ricerca binaria la modifica che ha introdotto un bug
   branch     Elenca, crea o elimina branch
   checkout   Checkout a branch or paths to the working tree
   clone      Clona un repository in una nuova directory
   commit     Registra modifiche nel repository
   diff       Show changes between commits, commit and working tree, etc
   fetch      Scarica oggetti e ref da un altro repository
   grep       Stampa le righe corrispondenti ad un modello
   init       Create an empty Git repository or reinitialize an existing one
   log        Mostra log del commit
   merge      Unisce due o più cronologie di sviluppo
   mv         Sposta o rinomina un file, una directory o un link simbolico
   pull       Fetch from and integrate with another repository or a local branch
   push       Aggiorna i ref remoti insieme agli oggetti associati
   rebase     Forward-port local commits to the updated upstream head
   reset      Ripristina l'HEAD corrente allo stato specificato
   rm         Remove files from the working tree and from the index
   show       Mostra vari tipi di oggetti
   status     Show the working tree status
   tag        Crea, elenca, elimina o verifica un oggetto tag firmato con GPG

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help ' or 'git help '
to read about a specific subcommand or concept.

What I must to see ?


other question: How I can to install it in Viper directly from github ?


mmm everything seems working fine with git, to install it in Viper directly from Github, clone Github project in

<p>and rename cloned folder to "rttl" to import it as community.floyd.rttl<br></p>


I don’t have the “community” folder.
My tree is:


I make ~/.zerynth/env/libs/community/floyd ?


exactly :slight_smile: