Coding

Raspbian with PIXEL includes the Python IDLE development and learning environment. There are two versions included - one for Python 2 and the other for Python 3. The LoCoRo project uses Python 3. Python IDLE provides an editor, debugger, class browser, and execution shell. If you do not have a prefered coding editor then Python 3 IDLE is a good choice.

The Py-LoCoRo is examples and package are written in Python and you program in Python to customize the robot and add new capabilities.

If you are new to Python then a good place to start is with one of the many on-line programming guides. If you have not preference, then consider starting with CodeAcademy. They provide a number of free courses as well as offering more in-depth courses for a fee. The CodeAcademy Python course starts with the basic syntax of the language and progresses through creating object oriented classes. It will provide the fundamentals needed to program a LoCoRo.

In addition the the fundamentals of Python programming, you will want to learn how to the LoCoRo hardware. Two interfaces to learn are I2C and GPIO.

  • I2C - a multi point serial interface - to interface between the Raspberry Pi and the actual controller board. There are other I2C devices including IR detectors for performing line-following, accelerometers and gyroscopes for creating smart-navigation, distance measuring sensors, and more.
  •  GPIO - general purpose input output - is the 40-pin connector on the Raspberry Pi. The GPIO may be used to connect sensors such as ultrasonic distance detectors, motion sensors, contact switches, and more. There are many low cost additions you can make to your LoCoRo.

Raspbian includes a GPIO library for Python. The documentation is somewhat sparse but the official examples wiki is a good resource as is almost any Google search which includes the library name.

The I2CPWMCONTROLLER package is included with the py-locoro project and was installed as part of the SD Card instructions. The documentation for the controller package is included in README.md and also available online as part of the py-locoro project on GitLab.

Suggestion: Open the file ~/py-locoro/examples/demo.py and read it while referencing the documentation.

© 2017 Bradan Lane Studios | all rights reserved