Added missing closing bracket.
Source Link
lwr20
  • 312
  • 2
  • 10

Capitalisation is important. You want serial.Serial() instead of serial.serial()

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.

Capitalisation is important. You want serial.Serial() instead of serial.serial()

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.

Capitalisation is important. You want serial.Serial() instead of serial.serial()

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.

Corrected path to serial device
Source Link
lwr20
  • 312
  • 2
  • 10

Capitalisation is important. You want serial.Serial()serial.Serial() instead of serial.serial()

You've also not put the correct path to the serial.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"/dev/ttyAMA0", baudrate=9600) 
ser.write("code") 
ser.close()

See http://www.elinux.org/Serial_port_programming for more examples.

Capitalisation is important. You want serial.Serial() instead of serial.serial()

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.

Capitalisation is important. You want serial.Serial() instead of serial.serial()

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.

Source Link
lwr20
  • 312
  • 2
  • 10

Capitalisation is important. You want serial.Serial() instead of serial.serial()

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.