A/Dコンバータの値を取り込む
MCP3008でボリュームの抵抗の変化を読み込む
# # python scucess version # at MCP3008 # import wiringpi as pi import time SPI_CH = 0 READ_CH = 0 pi.wiringPiSPISetup(SPI_CH,200000) while True: buffer = 0x6000 | (0x0400 * READ_CH) buffer = buffer.to_bytes(2, byteorder='big') pi.wiringPiSPIDataRW(SPI_CH, buffer) value = (buffer[0] * 256 + buffer[1]) & 0x3ff volt = value * 3.3 / 1023 print("DATA:" , value, " Volt:", volt, "V") time.sleep(0.5)
ボリュームを回すと抵抗値が変わります