Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Learning Beaglebone Python Programming

You're reading from   Learning Beaglebone Python Programming Unleash the potential of BeagleBone using Python

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781784399702
Length 196 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Alexander C Hiam Alexander C Hiam
Author Profile Icon Alexander C Hiam
Alexander C Hiam
Arrow right icon
View More author details
Toc

Buttons


A button is one of the simplest input devices you can connect to your BeagleBone. To sense the state of a button, we only need to use a single GPIO pin configured as an input. We haven't used a GPIO input yet, so let's take a look at a simple example first.

For this circuit, you will need:

  • Breadboard

  • 1x tactile switches

  • 1x 10 kΩ resistors

  • Jumper wires

A tactile switch is a type of momentary push button, meaning that it is only engaged while it is held down and returns to its default state when released. They are widely available from stores such as Adafruit and SparkFun, and it is also one of the more breadboard-friendly types of switches. Depending on the variety of tactile switch, it might require straightening the pins with a pair of pliers to get it to lock into your breadboard. Wire the switch to GPIO0_30 (P9.11), as shown in the figure:

Now run the following code and press the button; you should see a value of 0 normally and 1 when you press the button:

from bbio import *

SW_PIN ...
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 $19.99/month. Cancel anytime
Banner background image