Skip to Content
Programming with MicroPython
book

Programming with MicroPython

by Nicholas H. Tollervey
September 2017
Intermediate to advanced content levelIntermediate to advanced
214 pages
5h 27m
English
O'Reilly Media, Inc.
Content preview from Programming with MicroPython

Chapter 8. Input and Sensing

It is important for a device to react to interactions from users or changes in its environment. Such interactions are at the core of the device’s nonprogrammer user experience. For example, shaking the device to reset the state of the program, using the light sensor to change the intensity of the LEDs, or pressing a button to cycle through a series of options are all interactions that rely on the device processing input or sensing changes in its environment.

The devices described in this book do not have keyboards, mice, or touchscreens like traditional computing devices. So how are we to interact with them? Typing Python commands into a REPL might be fun for programmers, but this doesn’t address the needs of nontechnical users who need to communicate intents, instructions, or decisions in a manner that is intuitive, context sensitive, and perhaps even entertaining. Therefore, it’s important to consider how MicroPython works with input and sensors.

Collectively, the devices covered in this book have a wide variety of input and sensing capabilities available to them. Some, like the ESP8266/32-based devices, are limited only to one or two buttons; others, like the Circuit Playground Express and micro:bit, have all sorts of components through which users can interact with the device. In all cases, it is possible to connect external sensors and peripherals to the boards via GPIO pins, and the general prinicples of working with such hardware can be transferred ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Hands-On Embedded Programming with C++17

Hands-On Embedded Programming with C++17

Maya Posch
The Go Programming Language

The Go Programming Language

Alan A. A. Donovan, Brian W. Kernighan
Programming Rust, 2nd Edition

Programming Rust, 2nd Edition

Jim Blandy, Jason Orendorff, Leonora F. S. Tindall

Publisher Resources

ISBN: 9781491972724Errata PageSupplemental Content