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.
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 ...