Created
February 13, 2022 17:41
-
-
Save Park-Developer/9c383b1eb436b87f303ed4f13b40d32e to your computer and use it in GitHub Desktop.
Python : Serial
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import serial | |
from time import sleep | |
ser = serial.Serial ("/dev/ttyACM0", 9600) #Open port with baud rate | |
while True: | |
received_data = ser.read() #read serial port | |
sleep(0.03) | |
data_left = ser.inWaiting() #check for remaining byte | |
received_data += ser.read(data_left) | |
print (received_data.decode('ascii')) #print received data | |
ser.write(received_data) #transmit data serially | |
#출처: https://nowprogramming.tistory.com/28 [지금은 프로그래머] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment