The goal of this tutorial is to help you begin programming with Python to control your Arduino robots with a Raspberry PI. We will go over the basics like installation and some simple examples to control your robot from a Python GUI from Raspberry PI.
Step 1: Parts list
1. Raspberry PI ( with monitor, USB hub, keyboard, mouse,and WIFI Dongle)
2. Arduino UNO or compatiable (USB cable)
3. Wifi Router
Now when it comes to robot bases there are many kits available in size and complexity. In this tutorial I have decided on using this setup with a 12v battery that will give us long run times and high load capacity. And a power distribution board with regulated 12v and 5v power outputs that makes it easy to deliver power to our robot.
4. Robot Base
5. Motor Driver
6. Power Distribution Board
7. 12volt 7amp hr Battery
Step 2: Introduction to Python
Python is a general purpose interpreted, interactive, object-oriented, high-level programming language that was created by Guido van Rossum in the late eighties. Python allows users to write code with clear, readable syntax with a growing number of support libraries for various tasks that is open source and has a community based around its development. Here are some helpful links that might come in handy when starting out.
Step 3: Python Installation and setup
In order to get our Python programs running we need to ensure first that Python is installed on our system along with the proper dependencies and verify the version we are using. Now If you are using ” 2013-02-09-wheezy-raspbian.img ” image or later on your Raspberry Pi, Python should be pre-installed.
We can check our python version by using the terminal to verify.
Copy and paste in the LXterm
For the examples we are going to go over it is recommended that you use Python versions 2.6 or later. If Python is not installed on your system you can use apt-get granted your Raspberry Pi is connected to the Internet.
Copy and paste in the LXterm
sudo apt-get install python2.6
Install some of the the dependencies
sudo apt-get install python-serial
Now we have to make the programs executable with a chmod command
Copy and paste in LXterm
sudo chmod +x /home/pi/scanports-arduino.py
sudo chmod +x /home/pi/term.py
sudo chmod +x /home/pi/Buttons.py
The programs should now be executable and we can run them by double clicking them or via terminal. The last step is to download and load the sketch with the Arduino IDE.
Arduino Robot Base Sketch
If you are unfamiliar with Arduino and its IDE you can read up on it here.
And lastly refer to the wiring diagram above for setting up the power connections to the robot base.
For more detail: Building robots with Raspberry Pi and Python
Current Project / Post can also be found using:
- https://yandex ru/clck/jsredir?from=yandex ru;search;web;;&text=&etext=1827 WJWvr_B57dAuOwwAkCm4eOcYHk7zhPtvthpVlp2xHHfFpwXYbCmaWpnaRUOaoWxL 1d51253771ec689c2d0f6fc79538de8d2a383b97&uuid=&state=_BLhILn4SxNIvvL0W45KSic66uCIg23qh8iRG98qeIXme