Peripherals pt. 1 – Basics

Having a microcontroller for doing your desired purposes is fine. However, you usually do not want to do fancy scientific calculations or other stuff, but react and control your environment. For this reason, peripherals are inevitable.

With this post I would like to introduce several different sensors (input) and output possibilities.


At first, I would like to introduce some basic classes for basic digital and analog IO.
You may want to multiplex some pins one day. This is quite easy, but implementing this each time again is boring – why not use a generic interface for this reason?

This also requires a basic implementation that does not implement a multiplex behaviour:

Digital IO

Digital IO Interface:

Generic digital IO class header:

Generic digital IO class implementation:

Analog IO

And the same goes for analog IO as follows with an analog IO interface:

And furthermore a generic analog IO class header:

… and a simple implementation:

Next Part – Input here.

Leave a Reply