from machine import ADC, Pin
import time
NUM_WIRES = 8
adc_pins = [34, 35, 12, 33, 25, 26, 27, 14]
expected_voltages = [0.12, 0.36, 0.83, 1.43, 2.14, 3.0, 3.93, 5]
# Initialize ADC objects
adcs = [ADC(pin)for pin in adc_pins]
# Configure ADC width and attenuation
def read_voltage(adc):
adc_value = adc.read_u16()
voltage = (adc_value / 65535.0) * 3.3
return voltage
while True:
print("Wire Test Results:")
for i in range(NUM_WIRES):
voltage = read_voltage(adcs[i])
print(f"Wire {i + 1}: {voltage:.2f} V - ", end="")
if voltage < 0.1:
print("\u26A0 CUT!")
elif abs(voltage - expected_voltages[i]) > 0.3:
print("\u26A0 SWAPPED!")
else:
print("\u2705 OK")
print("-------------------")
time.sleep(2)