I loaded the Standard Firmata on Arduino and ran a Python3 program to test.
The Digital read & write work.
The Analog read works.
But the Analog write gives me an input configuration error ?
"OSError: Analog pin 5 is set up as an INPUT and can therefore not be written to"
analog_5 is defined in python as output ?
Here is the Python3 code:
import pyfirmata
from time import sleep
board = pyfirmata.Arduino('COM12')
it = pyfirmata.util.Iterator(board)
it.start()
sw = board.get_pin('d:2:i')
led = board.get_pin('d:11:o')
analog_0 = board.get_pin('a:0:i')
analog_5 = board.get_pin('a:5:o')
analog_0.enable_reporting()
while True:
value = sw.read()
print ("read value : ",value)
if value == 1:
led.write(1)
else:
led.write(0)
A0 = analog_0.read()
print ("read A0 : ",A0)
print ("read volts : ",(5*A0))
analog_5.write(A0)
sleep(1)
board.exit()