Data Sheet

UCTRONICS Ultimate Starter Leaning Kit for Raspberry Pi #K0064
107 www.uctronics.com
8.19 Project 19: LED Bar Graph
8.19.1 Overview
In this lesson, we will learn how to control an LED bar graph by programming the Raspberry
Pi.
8.19.2 Requirement
Raspberry Pi ×1
ADC0832 ×1
LED bar graph ×1
220Ω Resistor ×10
10KΩ Potentiometer ×1
Breadboard ×1
Several Jumper wires
8.19.3 Principle
1. What
s LED Bar Graph ?
The bar graph - a series of LEDs in a line, such as you see on an audio display - is a common
hardware display for analog sensors. It's made up of a series of LEDs in a row, an analog
input like a potentiometer, and a little code in between. You can buy multi-LED bar graph
displays fairly cheaply. This tutorial demonstrates how to control a series of LEDs in a row,
but can be applied to any series of digital outputs. This tutorial borrows from the For Loop
and Arrays tutorial as well as the Analog Input tutorial. The sketch works like this: first you
read the input. You map the input value to the output range, in this case ten LEDs. Then you
set up a for loop to iterate over the outputs. If the output's number in the series is lower than
the mapped input range, you turn it on. If not, you turn it off.