-
Notifications
You must be signed in to change notification settings - Fork 2
Raspberry Pi Arduino Connection
CaliW edited this page Mar 14, 2018
·
8 revisions
How to talk to Arduino through Raspberry Pi
- Connect power, HDMI cord, Ethernet cord, mouse, and keyboard to Raspberry Pi, leave off the Arduino USB for now.
- When desktop screen opens, click the terminal tab in the upper left corner, then click the applications menu (top left corner), click programming, then click python 3. This will open the raspberry pi terminal and the python shell terminal.
- In the raspberry pi terminal type:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install arduino
ls /dev/tty*
- The last command will print a long list of yellow /dev/ things. Now you plug in the Arduino and type the last command again (
ls /dev/tty*). - This time there will be 1 different entry. It will probably look like
/dev/ttyACM0.This is the USB port that the Arduino is plugged into. - Now move to the python shell terminal and type:
ser = serial.Serial(‘/dev/ttyACM0’, 9600)
I’m pretty sure this creates a ‘serial’ link between the terminal and the shell terminal, and the Arduino terminal we open next.
- Now that everything is set up, go to the applications menu again, click the programming tab and then click Arduino. It should have the standard green and white infinity sign next to it. This is where you enter all of the Arduino code you want to use.
For example: plug the 3 wire LED into ground, 5V (both on left side ports), and one of the numbered ports, let’s say 3 (these are the right side ports). Then try the code:
int led = 3;
Void setup()
{
pinMode(led, OUTPUT);
}
Void loop()
{
digitalWrite(led, HIGH);
delay(2000);
digitalWrite(led, LOW);
delay(2000);
} //endless 2 second on, off loop of blinking lght.