/pibot

Code worked on with my nephew for a experiment to build a Raspberry Pi based robot

Primary LanguagePython

PiBot

Code worked on with my nephew for a experiment to build a Raspberry Pi based robot

Setting up the Raspberry-Pi

For a new Raspberry Pi, or a new OS install, we need to install some applications and libraries.

Operating system packages

Run the following in the console:

sudo apt-get install git python3 python3-dev

Python libraries

Run the following in the console:

sudo pip3 install RPi.GPIO

Run the program from console

python3 robot.py

Settings up PyCharm for remote development

You can use Pycharm to edit code on your local machine, and run it remotely on the Raspberry Pi.

Setting up a project

When you open PyCharm, select to Open a project.

Open a Project

Then select the location where your project file are located.

Select location

Setting up Python Interpreter

This step tells PyCharm which version of Python to use. In this case, we tell it to use Python3 on your Raspberry Pi.

Go to File | Settings, select your project (Project: PiBot) and then Python Interpreter. Then select the cog and Add Remote.

Add remote interpreter

In the dialog that comes up, select SSH credentials and enter the IP address, username and password. Also set the interpreter to /usr/bin/python3

Configure remote interpreter

Setting up deployment to Raspberry Pi

This step tells PyCharm where to upload your code before running it.

Go to File | Settings, then "Build, Execution & Deployment". Under that group, select Deployment and press the + button.

Add Deployment

Configure the settings as per the following screenshot

Add Deployment Settings

The select "Options" on under Deployment on the left hand list and set the following configurations

Deployment Options

Setting up Run configuration

This step tells PyCharm what, and where we want to run the code

Add a new run configuration

Add run configuration

This screen will appear, then press the + button on the top left. Select "Python" from the list. Set the following in the configuration screen, and pick the robot.py file (which is what we want to run).

Run configuration

Select Robot PY

You can then, in theory, run the program by using the 'Play' button or the 'Bug' if you're debugging

Run