changeset 31:001f4b12fbc0

Fixes piezzoelectric not giving a sound.
author lukasgin@lukass-macbook-pro.local
date Thu, 23 Jun 2016 23:47:02 +0200
parents d23589b4df44
children 071f5f765ec8
files basics.rst
diffstat 1 files changed, 2 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/basics.rst	Thu Jun 23 23:44:16 2016 +0200
+++ b/basics.rst	Thu Jun 23 23:47:02 2016 +0200
@@ -316,7 +316,6 @@
 
     from machine import Pin, PWM
     import time
-
     tempo = 5
     tones = {
         'c': 262,
@@ -329,13 +328,14 @@
         'C': 523,
         ' ': 0,
     }
-    beeper = PWM(Pin(2, Pin.OUT))
+    beeper = PWM(Pin(14, Pin.OUT), freq=440, duty=512)
     melody = 'cdefgabC'
     rhythm = [8, 8, 8, 8, 8, 8, 8, 8]
 
     for tone, length in zip(melody, rhythm):
         beeper.freq(tones[tone])
         time.sleep(tempo/length)
+    	beeper.deinit()
 
 Unfortunately, the maximum frequency of PWM is currently 1000Hz, so you can't
 play any notes higher than that.