Blog#4 Implementation-- Pi Fest - Music/Audio Project
This blog is part of a blog series for the Pi-Fest Design Challenge.
- This blog will include the details of the implementation of my idea. A Video and photo's are used to show metronome working as designed
Firmware Implementation
This section will describe my implementation of the Firmware that will run on the PICO for my metronome Idea.
FIRMWARE CODE
from picozero import Pot, LED, Buzzer # Pot is short for Potentiometer Add LED from time import sleep # OLED from machine import Pin, I2C import ssd1306 dial = Pot(0) # Connected to pin A0 (GP26) led = LED(13) # Make sure this is the correct pin buzzer = Buzzer(18) # OLED # setup the I2C communication i2c = I2C(0, sda=Pin(16), scl=Pin(17)) display = ssd1306.SSD1306_I2C(128, 64, i2c) heart_min = 40 heart_max = 180 heart_range = heart_max - heart_min # Calculate the difference #bpm = 0 while True: bpm = heart_min + dial.value * heart_range # Convert dial value to BPM print(int(bpm)) # The following part changes according to what you want to display display.text('Beats Per Minute,', 0, 0) display.text('----------------', 0, 16) display.text(str(int(bpm)),50, 32) display.text('----------------', 0, 48) display.show() beat = 60/bpm brighter_time = beat / 2 # Spend half a beat getting brighter dimmer_time = beat / 2 # Spend half a beat getting dimmer print(brighter_time) print(dimmer_time) #led.pulse(brighter_time, dimmer_time, n=1, wait=True) # Pulse 1 time, waiting until finished sleep(brighter_time) #display.poweron() led.on() # buzzer.beep(brighter_time, dimmer_time, n=1, wait=True) buzzer.beep(.10, .25, n=1, wait=True) #display.text(str(0),50, 32) #display.poweroff() led.off() sleep(dimmer_time)
Hardware Implementation
This section will describe the implementation of the circuit using the Pico and other electronics, to implement my metronome idea.
VIDEO
References
This section includes some links that I found helpful.
Top Comments