Raspberry Pi serial query
ls /dev/tty*
By plug found in a
Is him.
arudnio Code
void setup() { Serial.begin(9600); //打开串口 } void loop() { Serial.println("Hello Raspberry,I am Arduino."); delay(1000); if ( Serial.available()) { if('s' == Serial.read()) Serial.println("Hello Raspberry,I am Arduino."); } }
# - * - Coding: UTF-. 8 - * Import Serial Import Time Ser serial.Serial = ( '/ dev / ttyUSB0', 9600) IF ser.isOpen == False: ser.open () # open the serial port ser.write ( b "Raspberry PI IS READY") the try: the while True: size = ser.inWaiting () # get buffer character IF size = 0:! the Response = ser.read (size) # reads the contents and displays Print (the Response) Ser .flushInput () # empty the receive buffer zone time.sleep (0.1) # software delay the except KeyboardInterrupt: ser.close ()