Getting Started with Arduino on your Raspberry Pi (Linux)
Posted on January 19, 2014 by super
(This entire tutorial was created from start to finish on our Raspberry Pi model B with Noobs, running the Raspbian OS and using GIMP for screen captures and image editing.)
In this tutorial you will learn how to get your Arduino set up and running with Linux Via a Raspberry Pi.
The Arduino is an amazing little microcontroller loaded with thousands of possibilities, but it can be difficult to know where to start if you’re new to the world of microcontrollers. In the following tutorial, you will learn how to get your Arduino fully installed on your Raspberry Pi and running its first simple program.
Step One: Get an Arduino
If you are new to Arduino, you will want to start by purchasing a genuine Italian Arduino Uno Rev 3. This board is small, of high quality, and is one of the best documented and best supported microcontroller development boards in the world. You can easily find hundreds of books and blogs devoted to projects for this specific board, and numerous support forums dedicated to it. Likewise, it’s the most compatible with existing shields and libraries—a fact which will likely save you headaches later on.
Step Two: Get a USB A to be B Cable
You’ll need to be able to plug your Arduino into your Pi in order to upload code to it and give it instructions (you will need to pair your Pi with a USB hub in order to have enough USB connections for a mouse, keyboard, and your Arduino). The Arduino Uno uses a USB ‘A to B’ cable. The ‘A’ end is the standard type of USB connector that your Pi has two ports for. The ‘B’ side is a bit less common and looks like this:
- USB B head
Step Three: Get the Software
Arduino provides a free basic ‘sketchpad’ program that you will need to transfer code (instructions) over to your Arduino. You’ll need to get this set up before you can use your Arduino for anything. Fortunately, this is as easy as, well, Pi. (Sorry, I couldn’t resist.)
Open up LX Terminal, this handy little program that sits on the Desktop screen in Raspbian:
It’s a good idea to run an update first (my software wouldn’t work when I installed it without running the update first), so once at the command prompt, type the following:
Let the update run, then type:
This will install your software — if the install goes smoothly, in your start menu a new category called ‘electronics’ will appear, and hovering your cursor over it will bring up the menu item to load the Arduino software. Start it up and then simply verify your board type and Serial Port and you’re ready to upload:
First, go to Tools -> Board and select your model of board:
Then go to Tools -> Serial Port and select the com port your Arduino is on.
Step Four: Test your Arduino and Pi pairing by uploading an example sketch.
Go to File -> Examples -> Basics -> Blink and select the program.
If your Arduino is hooked up to Pi correctly, you should see a couple of the LED lights start to flash every time you hit ‘Upload’. See the picture below to check which lights you should observe as you hit the ‘Upload’ button:
Congratulations! Your Raspberry Pi can now give your Arduino instructions.