Simple serial port example using Python.

preview_player
Показать описание
Simple serial port hardware loop back programming using Python.
I have used COM4 (USB-Serial converter) and shorted TX(pin-2) and RX(pin-3).

Code:
import serial
from time import sleep

ser = serial.Serial(port='COM4',baudrate=9600,parity=serial.PARITY_NONE,stopbits=serial.STOPBITS_ONE,bytesize=serial.EIGHTBITS,timeout=0)
sleep(1)
print(a)
Рекомендации по теме
Комментарии
Автор

hi,
i got the following error when trying to import the serial port .could help me on this??

"AttributeError: module 'serial' has no attribute 'serial' "

sumeetp
Автор

Hi
Pip install pyserial is not working.
It says pip is not recognised as an Internal or external command.
Kindly help

rakhimittal