Serial Communication between Raspberry Pi & Arduino

From ESE205 Wiki
Revision as of 16:54, 10 December 2017 by Sycstudent (talk | contribs) (Created page with "==From Arduino to Raspberry Pi== '''Arduino code'''<br/> A sample arduino code is created below. The code is very simple—printing “Hello World!” every two seconds. <br/>...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

From Arduino to Raspberry Pi

Arduino code
A sample arduino code is created below. The code is very simple—printing “Hello World!” every two seconds.

void setup(){
  Serial.begin(9600);
}

void loop(){
  Serial.println("Hello World!");   
  delay(2000);
}

Figuring out the port
Then, we need to figure out the port that connects Raspberry Pi & Arduino. Type in the following code without your Arduino plugged into Raspberry Pi. The command means to list out all the ports with the beginning of "tty".
pi@raspberrypi $ ls /dev/ttty* Then connects the two devices with your USB cable, and type in the command above again. There shall be a new port appears; if that is the case, the new name is the port name of your Arduino.


From Raspberry Pi to Arduino