Micropython Lesson 5
Generate a tone on the onboard Buzzer from square waves
- generating square waves
For this example, we use the piezo buzzer wired to pin 25 of the Magicbit.
from machine import Pin,PWM import time BUZZER=Pin(25, Pin.OUT) while True: BUZZER.on() time.sleep_ms(300) BUZZER.off() time.sleep_ms(300)
Note:: Create a program that plays one frequency when one push button on the board is pressed, and another frequency when the other push-button when pressed.