so, i am trying to get an input from a joystick hooked upto an arduino in python and then multiplying it's input value by 1023, but every time i try to multiply the input, the arduino returns the value of x and y as None, but as soon as i get rid of the multiplication, it works as normal, what could be the problem? here's my code:
import pyfirmata
import time
board = pyfirmata.Arduino('COM3')
it = pyfirmata.util.Iterator(board)
it.start()
board.analog[0].mode=pyfirmata.INPUT
board.analog[0].mode=pyfirmata.INPUT
board.analog[0].enable_reporting()
board.analog[1].enable_reporting()
board.digital[6].mode=pyfirmata.INPUT
while True:
x=board.analog[0].read()
y=board.analog[1].read()
x=x*1023
y=y*1023
print(x,y)
time.sleep(0.5)
Some kind of serialization error is probably occurring, the pyfirmata library doesn't seem to have any kind of serialization error handling , and the library is likely populating your analog values with None.
It will be up to you to handle transmission and serialization errors:
Another tip to avoid serialization issues: