Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
BeagleBone By Example

You're reading from  BeagleBone By Example

Product type Book
Published in Aug 2016
Publisher Packt
ISBN-13 9781785285059
Pages 262 pages
Edition 1st Edition
Languages

Table of Contents (17) Chapters

BeagleBone By Example
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Getting Started with BeagleBone Circuit Fundamentals and GPIO Introduction to Physical Computing Systems Real-time Physical Computing Systems Using BeagleBone Connecting Physical Computing Systems to the Internet Home Automation Using BeagleBone Working with Images Using Computer Vision Home Security Systems Using BeagleBone Black Exploring Robotics Building Your Own Robot 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...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}