7

(avery) #1

Arduino programming: Stacks, classes, and scrolling displays


SCHOOL OF MAKING


Arduino programming:


Stacks, classes,


and scrolling displays


Learn new code skills and impress your friends with the coolest


looking thermometer in the land


I


n our previous Arduino tutorial, we
expanded both our C programming
knowledge and our data visualisation
potential by using a library – we stood
on the metaphorical shoulders of
giants and imported code written by
other developers. Rather than being a cheat
or a lazy option, this is how nearly every project
is developed. Libraries, and their close relation,
the API, allow programmers to utilise all kinds of
advanced functionality without having to constantly
reinvent the wheel. Not only that, but you also
benefit from the programming wisdom that goes
into the development of a library, wisdom that can
sometimes stretch generations when dealing with

old system libraries, more true when programming
with C than many modern languages.
We’re going to use a couple of new libraries in
this tutorial to do some magical stuff that would
otherwise take a year’s worth of tutorials. We’ll
use the same temperature and humidity sensor
from before, but we’re moving on from the hipster
austerity of seven-segment displays to a whole
new world of usefulness – a real bona fide screen.
The screen we’re using is known as an SSD1306.
It’s commonly available and costs very little, and
yet has a bright OLED display with a resolution
of 128 × 64. It’s also tiny, making it perfect for
embedded projects where you need to output a
few more details than a couple of numbers. In fact,

YOU’LL NEED
SSD1306
monochrome
0.96” 128 × 64
OLED graphic
display
DHT11 digital
temperature and
humidity sensor

Right
The completed
project shows both
temperature and
humidity, alongside
a chart for recent
temperature changes

Graham Morrison
@degville

Graham is a veteran
Linux journalist who is
on a life-long quest to
find music in the perfect
arrangement of silicon

Free download pdf