Introduction: How to Control a Robot Using a Serial Connection

About: Professionally, I divide my time between my IT company and my property investment company. Personally, I enjoy spending time with my husband riding bikes, and finding new projects that make fun, useful (and s…
Here are instructions on how to make a serial connection between a Rapsberry Pi and Arduino using a USB cable.  Once a serial connection has been established, it can be used to control whatever you can dream up.  In this case I used the Pi as a remote control on a Power Wheels tractor, using Arduino and relays.

Step 1: Shut Off All Serial Action Going on With the Pi.

You have to edit two places.  The first ‘/boot/cmdline.txt’ - delete

console=ttyAMA0,115200 kgdboc=ttyAMA0,115200

Then bounce over to /etc/inittab and we have to comment out the last line by adding the # to the beginning.

#T0:23:respawn:/sbin/getty -L ttyAMA0 115200 vt100


Reboot with your Arduino plugged in and make sure you have the proper power.

Step 2: Download a Serial Terminal Like Minicom or Cu. I Like Cu.

sudo apt-get install cu

CU is a serial terminal viewer that allows you to directly send keystrokes over your serial port.

Step 3: Figure Out Where Your Arduino Can Be Accessed.

Make sure that you have already uploaded a script that is waiting for a serial connection.  Most likely as a Raspberry Pi user it will be ‘/dev/ttyACM0′ but to be sure I did a quick ‘ls -l /etc/serial/by-path’ and got the following answer:

lrwxrwxrwx 1 root root 13 Dec 31  1969 platform-bcm2708_usb-usb-0:1.2:1.0 -> ../../ttyACM0

Step 4: Enjoy the Magic of Sending Bits Over the Wire.

Connect with your serial terminal client – in my case:

cu -l /dev/ttyACM0 -s 9600

and you should see a connected message


Visit http://thomasloughlin.com/serial-connection-between-raspberry-pi-and-arduino/ for sample code and more in-depth details on the connection.

Step 5: Figure Out What You Are Going to Do With This New Serial Knowledge.