from machine import I2C, Pin, PWM
from picozero import Button, Pot
from time import sleep
from pico_i2c_lcd import I2cLcd
buzzer = PWM(Pin(15)) # connect buzzer to GP15
button = Pin(9, Pin.IN)
pot = Pot(26)
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
I2C_ADDR = i2c.scan()[0]
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
def play_tone(freq, duration):
buzzer.freq(freq)
buzzer.duty_u16(32768) # 50% duty cycle
sleep(duration)
buzzer.duty_u16(0) # stop sound
melody = [
(262, 0.3), # C
(294, 0.3), # D
(330, 0.3), # E
(349, 0.3), # F
(392, 0.5), # G
]
play_melody = False
print('banaan')
M = [
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111,
0b11111
]
lcd.custom_char(0, M)
while True:
print(pot.value, pot.voltage)
sleep(0.1)
# if play_melody:
# for note, duration in melody:
# play_tone(note, duration)
# sleep(0.05)
# play_melody = False
# if button.value() == 1:
# print('Halllo')
# play_melody = True
# lcd.putstr(chr(0))
# sleep(5) # "Hello world!" text would be displayed for 5 secs
# lcd.clear()
# sleep(1) # clear the text for 1 sec then print the text againEmergency toggle
Audio (buzzer?) (side)
OK
Emergency button
Binary counters
16
8
4
2
1
+
-
Potmeter
32
64