Strategy 1 – Keeping the code on a PC and uploading it
Secure File Transfer Protocol (SFTP) lets you transfer files from a computer to a Pi. This strategy enables you to write code on your computer, then upload it to the Raspberry Pi. You can choose your editor and have the safety of more than one copy.
Important note
But wait – which editor? Editing code requires software designed for this purpose. Recommendations for Python are Mu, Microsoft VS Code, Notepad++, and PyCharm.
SFTP uses SSH to copy files to and from the Raspberry Pi over the network. So, let's see how to do it:
- First, make yourself a folder on the PC to store your robot code in; for example,
my_robot_project
. - Inside that folder, make a test file, using your editor, that will just print a bit of text. Put this code into a file named
hello.py
:print("Raspberry Pi is alive")
- We will copy this to the robot and run it. You can make the copy using the SFTP tool FileZilla...