find a solution about run python program getting error simple program
import serial ser =serial.serial ("dev/ttyAMA0",baudrate = 9600) ser.write("code") ser.close() error attributeerror 'module' object has no attribute 'serial'
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It only takes a minute to sign up.Sign up to join this community
Capitalisation is important. You want
serial.Serial() instead of
You've also not put the correct path to the serial device -
dev/ttyAMA0 would be relative to the place the user runs the script from (so would only work if you run it from
Your code should be:
import serial ser = serial.Serial("/dev/ttyAMA0", baudrate=9600) ser.write("code") ser.close()
See http://www.elinux.org/Serial_port_programming for more examples.