Reputation: 1
I want to send a number(say 90) from python to arduino through pyserial. But I guess arduino works with ASCII only. So how do I read the integer 90 in arduino ? please help...
Upvotes: 0
Views: 1821
Reputation: 659
In Python it is easy to convert a number as a string: You can just do
str(90)
https://docs.python.org/3/library/functions.html#func-str
Then in the Arduino code, you can use
parseInt()
https://www.arduino.cc/en/Serial/ParseInt
Or you can just send binary data over the serial line. If your number is always between 0 and 255, you can just send one byte. Otherwise you will have to send the number in several bytes.
Upvotes: 1