Wiki Raspberry Python

HAMKit Wiki Repository
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages
Filter by Categories
 HAMKit Wiki
News and Information
Raspberry Pi
VMAC PiHat v1

Now, you have your super small computer (Pi), and would like to do something with it.  Programming does not need to be complicated and daunting, it is just the environment which needs to offer the right tools for the job.


Python is an easy to use, but powerful, programming language and together with a Raspberry Pi, forms a very flexible development environment and is also great for other ad-hoc programming tasks.

Sample code provided by HAMKit is formed on Python and uses a file extension of .py   Some further reading  on Python can be found at Raspberry Pi Python Basics

Example HAMKit Code

Examples of HAMKit VMAC PiHat test code can be found in our downloads area.

Editing Code

You can create, or edit, Python using a basic text editor such as notepad or an editor like Thonny which is both easy to use and more importantly correctly structures, and colour codes the commands (making it even easier).   The Raspberry Pi Raspbian comes preloaded with Thonny.

The small Thonny application can also be used on a computer, so allowing you to learn, update code and then copy to the Pi.

Hint:  Python does not use curly braces but instead requires indentation for nesting code.

Running Code

A Python ‘script’ file can be run from within Thonny, or simply from command line through the terminal.

To run a Python program from Thonny, simply load the file into the editor and click the run, as shown.

To run a Python program from the command line, open the Terminal (CTL ALT T), go to the path of the file and enter python [file name]

This means you can easily script Python, so it auto loads/runs on the Raspberry Pi power up for example.

python VMAC\ PiHat\ -\ Test\ Loop\ Example\ Code\ to\ Setup\ GPIO\ and\ I2C\

Hint: When entering text on the command line, to save typing, you can start whatever you entering and then press TAB.  example.  pyt and TAB will auto complete to python.  Then press space and then repeat the first few characters of the  part, complete the following text on the commend line.

Example: First go to the Desktop folder and then  pyt TAB SPACE VM TAB – should give you the above.

Remember: Linux commands are Case Sensitive, so if the folder or filename is capitalised, like Desktop for example, you will need to enter capital D and not lower case d.

Renaming: Long filenames with spaces may look confusing.  If you rename the file from ‘VMAC\ PiHat\ -\ Test\ Loop\ Example\ Code\ to\ Setup\ GPIO\ and\ I2C\’ to ‘’, the comand line would look like this.  The syntax is mv oldfilename newfilname Once you have renamed you can then run the python script as shown underneath.

pi@raspberrypi:~/Desktop $ mv VMAC\ PiHat\ -\ Test\ Loop\ Example\ Code\ to\ Setup\ GPIO\ and\ I2C\
pi@raspberrypi:~/Desktop $ python

The important thing, is to enjoy learning..

Please feel free to share our product love through the below

HAMKit | Facebook Comments