rpi-interface-board/rpi-scripts/examples/read_analog_inputs.py

20 lines
492 B
Python

# Include external libraries
import os
import sys
import time
from mcp3208 import MCP3208
# Include custom files
# Add the parent directory to the module search path
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "..")))
from interface_board_libs.adc_mcp3208 import MCP3208
from interface_board_pins import ADC_CHANNELS
adc = MCP3208()
while True:
for i in range(8):
print('ADC[{}]: {:.2f}'.format(i, adc.read(i)))
time.sleep(0.5)