Code worked on with my nephew for a experiment to build a Raspberry Pi based robot
For a new Raspberry Pi, or a new OS install, we need to install some applications and libraries.
Run the following in the console:
sudo apt-get install git python3 python3-dev
Run the following in the console:
sudo pip3 install RPi.GPIO
python3 robot.py
You can use Pycharm to edit code on your local machine, and run it remotely on the Raspberry Pi.
When you open PyCharm, select to Open a project.
Then select the location where your project file are located.
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.
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
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.
Configure the settings as per the following screenshot
The select "Options" on under Deployment on the left hand list and set the following configurations
This step tells PyCharm what, and where we want to run the code
Add a new 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).
You can then, in theory, run the program by using the 'Play' button or the 'Bug' if you're debugging