Skip to content

Commit

Permalink
updated microbit example just to keep it simple
Browse files Browse the repository at this point in the history
  • Loading branch information
cpmpercussion committed Aug 21, 2024
1 parent 3f5279c commit 5cf2b81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion configs/serial-example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ timescale = 1

# Serial mapping
[serial]
port = "/dev/tty.usbmodem102" # default GPIO serial port on raspberry pi
port = "/dev/tty.usbmodem1102" # default GPIO serial port on raspberry pi
baudrate = 115200 # a typical default choice of baudrate
6 changes: 4 additions & 2 deletions examples/microbit_serial_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,17 @@ def float_to_freq(value_in):
"""maps a float 0-1 to a frequency."""
base = 220
top = 880
return int(base + (value_in * (top - base)))
out = int(base + (value_in * (top - base)))
out = max(0, min(out, 999))
return out

def play_freqs(freqs):
global last_played_freqs
if freqs != last_played_freqs:
eff = audio.SoundEffect(
freq_start=freqs[0],
freq_end=freqs[1],
duration=freqs[2]*3,
duration=freqs[2],
vol_start=255,
vol_end=255
)
Expand Down

0 comments on commit 5cf2b81

Please sign in to comment.