LFO patch

This commit is contained in:
Mikayla Dobson
2023-04-12 17:01:07 -05:00
parent 4c91814545
commit 338b0756c8
2 changed files with 92 additions and 50 deletions

22
MCP3008.py Normal file
View File

@@ -0,0 +1,22 @@
import machine
# adapted from MCCP3008 class by @romilly, which was adapted from Adafruit CircuitPython driver
# source: https://github.com/romilly/pico-code/blob/master/src/pico_code/pico/mcp3008/mcp3008.py
class MCP3008:
def __init__(self, spi: machine.SPI, chip_select: machine.Pin, ref_voltage=3.3):
self.chip_select = chip_select
self.chip_select.value(1)
self._spi = spi
self._out_buffer = bytearray(3)
self._out_buffer[0] = 0x01
self._in_buffer = bytearray(3)
self._ref_voltage = ref_voltage
def get_voltage(self):
return self._ref_voltage
def read(self, pin):
self.chip_select.value(0)
self._out_buffer[1] = pin << 4
self._spi