Skip to content

13. Output devices

The assignment this week requires to add an output device to a microcontroller board previously designed. In the Input Devices assignment, it was designed an board with an input device (a distance sensor). This week I decided to add an OLED in this board to show the distance.

Prototype

Before milling the board with the components for the assignement, I have setup a breadboard with the intented circuit of the PCB to test if it will work. I have used the ATtiny85 as microcontroller and a simple led to check if the code is being executed correctly.

I have draw a simple code at Blokkencode.ingegno using the library U8g2lib that manage the OLED device. This tool allow to generate C code that can be loaded in the microcontroller via blocks of components. It was not possible to compile the generated code for ATtiny85, because the library is too big and exceed the memory available of the microcontroller.

The solution was to find a light library that could be loaded in the available memory of ATtiny85. After some research, it was found the tiny4koled library native in the ArduinoIDE. After adding the library in the ArduinoIDE (menu: Sketch > Include Library > Manage Libraries…), I have tried to load the simple code on how to use the library (show below). This code was able to compile and load in the ATtiny85. The text was being shown as expected after add the VCC and GND in the microcontroller.

This library is available at Git Tiny4kOLED.

Designing PCB

Knowing that is possible to use the OLED and ATtiny85 microcontroller, it was designed the circuit containing besides these components, one led (and resistence) for supporting the elaboration of the code; ISP connection to program the ATtiny85, and Serial output for monitoring. I have used EasyEDA cloud software to design the board to learn about this tool. It has integrated several footprint for diverse components that can easily be added in your circuit and adapted as desired. It also provides a 3D view of your PCB and if you want you can even order the necessary components for your board and even order the PCB done. We skip this facility and designed by ourselves the board.

A detailed section on how this PCB was made was provided in the assignment Input Devices. Please checkout the section PCB Design - second try, subsections Milling board and Soldering. You can also find the files to mill the board there.

Programming

The code to show the value from the distance sensor in the OLED was straightforward. The code that controls the sensor was read and we just need to include the code that manage the OLED and show the sensor value. I tried to keep using the library SoftwareSerial.h to be able to send code via Serial, but it was not possible to upload all libraries together due to the memory available. So, from the code that manages the sensor, it was removed the library SoftwareSerial.h and kept only the library for the sensor. It was added the library and code to manage the OLED and shows the sensor value. the code was uploaded and the board worked as expected.

Second video, showing the output device closer.

Download the INO file from the microcontroller code.

Group Assignment

Ingegno - Output devices


Last update: August 30, 2022