Book Image

BeagleBone By Example

By : Pei JIA, Jayakarthigeyan Prabakar, Alexander Hiam
Book Image

BeagleBone By Example

By: Pei JIA, Jayakarthigeyan Prabakar, Alexander Hiam

Overview of this book

BeagleBone is a low cost, community-supported development platform to develop a variety of electronic projects. This book will introduce you to BeagleBone and get you building fun, cool, and innovative projects with it. Start with the specifications of BeagleBone Black and its operating systems, then get to grips with the GPIOs available in BeagleBone Black. Work through four types of exciting projects: building real-time physical computing systems, home automation, image processing for a security system, and building your own tele-controlled robot and learn the fundamentals of a variety of projects in a single book. By the end of this book, you will be able to write code for BeagleBone in order to operate hardware and impart decision-making capabilities with the help of efficient coding in Python.
Table of Contents (17 chapters)
BeagleBone By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Project – blinking an LED using Python script


In the previous section, we saw how we can access the GPIO pin from Python's interactive shell and change its state. Let's now write a python code and save it as a .py file and run it like we did at the end of the previous chapter. The python program that is discussed in this section will make an LED blink at an interval of 1 second. The LED will be On for 1 second and Off for another 1 second; this will loop continuously until you break the loop.

The following screenshot shows the program:

The code imports the time module and the Adafruit_BBIO module just as we did in the interactive shell in the previous section of this chapter and then we set up GPIO_60 as an output pin and then changed the state of the pin to HIGH and LOW in the while loop that runs continuously. We use the time.sleep(1) function to pause the code for 1 second in between the state changes. The code also has the GPIO.clean() function that gets executed when a keyboard interrupt...