BIVBlog #48: Microcontroller Input and Portability Basics

Reading basic digital input with a microcontroller is fairly straightforward—at least as long as you really keep things simple and don’t do some of the advanced stuff following in the next few episodes.

The biggest problem, or at least annoyance, at this point is to figure out how the I/O registers (aka. “special function registers”, aka. “ports” in the Intel world, if memory serves me correctly) are named in your development environment and for the particular microcontroller you want to use.

And of course the PIC has a little peculiarity in stock which you simply need to know about…

Table of Contents

00:00:25 Using a toggle switch connected to VCC and GND as input
00:01:40 My new breadboards-on-a-real-breadboard setup
00:02:20 My (not quite so new) 8-LED strips, in multiple variants
00:04:05 Hooking up the toggle switch
00:04:50 Using current limiting series resistors
00:08:00 Abusing beaded sewing pins as breadboard markers
00:08:55 The software side
00:09:10 Making the code portable, and easier to grasp as well
00:11:50 Notational conventions for bits within an integral type
00:12:10 Input on the Atmel AVR (ATmega 328p)
00:12:45 … and the TI MSP430 (G2553)
00:13:05 … and the MCP PIC (16F887), with the usual bonus surprise

Resources

bivblog48-basic-input-20161209-133700.tar.gz with the sources of the demo program I use in this episode (BSD license, as usual).
Updated microcontroller cheat sheets with additional information on using GPIOs for input.

About

Long term IPv6 evangelist/book author/trainer/consultant and generic Unix guy (*BSD, Linux, Solaris, and about a dozen more).

Leave a Reply

Your email address will not be published.