python - Arduino Serial programming issue -


i'm sending integer python using pyserial.

import serial ser = serial.serial('/dev/cu.usbmodem1421', 9600); ser.write(b'5'); 

when compile,the receiver led on arduino blinks.however want cross check if integer received arduino. cannot use serial.println() because port busy. cannot run serial monitor first on arduino , run python script because port busy. how can achieve this?

you listen arduino's reply additional code.

import serial ser = serial.serial('/dev/cu.usbmodem1421', 9600); # timeout after second  while ser.isopen():     try:         ser.write(b'5');         while not ser.inwaiting():  # wait till something's received             pass         print(str(ser.read(), encoding='ascii'))  #decode , print     except keyboardinterrupt:  # close port ctrl+c         ser.close() 

use serial.print() print arduino receives serial port, python code listening.


Comments

Popular posts from this blog

html - Styling progress bar with inline style -

java - Oracle Sql developer error: could not install some modules -

How to use autoclose brackets in Jupyter notebook? -