- # bi directional midi example for Adafruit MIDI Featherwing on M4 Express.
- import board
- import busio
- import time
- #midiuart = busio.UART(board.SDA, board.SCL, baudrate=31250)
- midiuart = busio.UART(board.TX, board.RX, baudrate=31250, timeout=0)
- print("MIDI UART EXAMPLE")
- toggleState = "off"
- lastTickTime = time.time()
- while True:
- data = midiuart.read(1) # read up to 32 bytes
- if data is not None:
- print("incoming"+str(data))
- currentTime = time.time()
- elapsedTickTime = currentTime - lastTickTime
- if (elapsedTickTime > 1.0):
- print("tick",str(currentTime))
- lastTickTime = currentTime
- if (toggleState == "off"):
- toggleState = "on"
- midiuart.write(bytes([0x90, 0x3C, 0x40]))
- else:
- toggleState = "off"
- midiuart.write(bytes([0x80, 0x3C, 0x40]))
Untitled
Posted by Anonymous on Thu 24th Sep 2020 22:58
raw | new post
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.