O'Reilly logo

Getting Started with Cubieboard by Olliver M. Schinagl

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Reading a switch

Reading the status of a switch is similar to writing to the LED. All the prerequisites apply equally. The only difference is that the GPIO is read via cat, rather than written via echo, as shown here:

packt@PacktPublishing:~ $ cat /sys/devices/virtual/misc/sunxi-gpio/pin/pb03
1

Using this knowledge, reading a button can be done from various programming languages in various forms.

Tip

A good exercise can be to write a simple script that reads the status of the button and makes the LED reflect this status. Both of the previous examples use the same pin as GPIO, so a second pin will need to be configured as GPIO if not already configured.

From here on out, there are many more ways and methods to interact. There are analog-to-digital ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required