I connect my Rasberry Pi to Arduino Nano (Uno) and all works when I send every command through python shell:
pi@raspberrypi ~ $ python2
Python 2.7.3 (default, Mar 18 2014, 05:13:23)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import serial
>>> ser = serial.Serial('/dev/arduino_nano', 9600)
>>> ser.write('4')
1
If I'm trying run script (below) with this commands, don't happen anything. A little note: if I run scripts with running python shell in other SSH session, script works excellent, and if I'm running screen command (sudo screen /dev/ttyUSB0 115200), script also works well. Script:
#!/usr/bin/env python
import serial
import time
ser = serial.Serial('/dev/arduino_nano', 9600)
ser.write('4')
print("Test")
So, I think my problem relationships with run serial connect.
print("this")is python3,print "this"is python2