Thanks a lot, the thread you mentioned is useful and I will try your method.
However, during my research on how to receive a feedback from Arduino using python, I try the code on:
But it didn't work the code is simple, but I cannot establish the connection to Arduino using Python.
when running this line of code:
board = Arduino('COM6')
there is an error:
TypeError Traceback (most recent call last)
in
7 import time
8
----> 9 board = Arduino('COM6')
10 iterator = util.Iterator(board)
11 iterator.start()
~\Anaconda3\lib\site-packages\pyfirmata_init_.py in init(self, *args, **kwargs)
17 args = list(args)
18 args.append(BOARDS['arduino'])
---> 19 super(Arduino, self).init(*args, **kwargs)
20
21 def str(self):
~\Anaconda3\lib\site-packages\pyfirmata\pyfirmata.py in init(self, port, layout, baudrate, name, timeout)
105 # Iterate over the first messages to get firmware data
106 while self.bytes_available():
--> 107 self.iterate()
108 # TODO Test whether we got a firmware name and version, otherwise there
109 # probably isn't any Firmata installed
~\Anaconda3\lib\site-packages\pyfirmata\pyfirmata.py in iterate(self)
280 received_data.append(data & 0x0F)
281 while len(received_data) < handler.bytes_needed:
--> 282 received_data.append(ord(self.sp.read()))
283 elif data == START_SYSEX:
284 data = ord(self.sp.read())
TypeError: ord() expected a character, but string of length 0 found
I have checked the Arduino board is connected to COM6 and no other devices are using the same port.
Thanks a lot for your help.