0% found this document useful (0 votes)
24 views2 pages

Lab8 - Digital Level

The document describes a lab assignment to build a 2D digital level using an accelerometer and LED matrix. Students are asked to write software to read accelerometer data and display a bubble on the LED matrix indicating the device's orientation. When level, the bubble should be centered, and it should move as the device is tilted in the x or y directions.

Uploaded by

Instructor Ko
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views2 pages

Lab8 - Digital Level

The document describes a lab assignment to build a 2D digital level using an accelerometer and LED matrix. Students are asked to write software to read accelerometer data and display a bubble on the LED matrix indicating the device's orientation. When level, the bubble should be centered, and it should move as the device is tilted in the x or y directions.

Uploaded by

Instructor Ko
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

E85: Digital Electronics and Computer Engineering

Lab 8: Digital Level

Objective
The purpose of this lab is to write embedded software to control external
peripherals. Specifically, you will build a 2D digital level with an accelerometer and
LED matrix. The LED matrix should display a “bubble” indicating whether the
accelerometer is level along the x and y axes.

1. System Requirements
Your system should include a Nucleo board, an Adafruit LIS3DH triple-axis
accelerometer breakout board, a KWM-20882CVB 8x8 LED matrix, and resistors
for the LED matrix, all wired together on a breadboard.
The system should use 7x7 of the LEDs to display a bubble indicating the
orientation of the accelerometer. When the accelerometer is level, the bubble
should be in the center. For each 2 degrees that you tilt the accelerometer in the x
or y directions, the bubble should move one dot in the corresponding direction on the
LED matrix. The bubble should stop at the edge of the matrix if the tilt is too great.

2. Suggested Approach
a) Browse the datasheets for the accelerometer and LED matrix on the class page
until you understand how they work.
b) Wire the accelerometer to your Nucleo board as shown below.

c) Run the lab8starter.c SPI sample code. Make sure that you can read the ID
register as expected, and then that you can get reasonable readings from the
accelerometer. Calibrate your accelerometer by identifying the readings when it
is level and how they change as you tilt it.
d) Turn on an LED in your LED array using a resistor and power and ground to
make sure you understand how the LED array operates. Remember that you

Page 1 of 2
may burn out the LED array if you don’t include the current-limiting resistor.
Pay attention to the pin numbering in the datasheet.
e) Hook the LED array up to the ports of your Nucleo board, taking care to use
current-limiting resistors appropriately. Note that, according to the Nucleo
datasheet, D4 and D5 are bridged to other pins and cannot be used reliably for
GPIO. Write and test a C function to turn on an LED given an (x, y) coordinate.
f) Write the rest of your program to periodically read the accelerometer, convert
the reading to a tilt in the x and y directions, and turn on the appropriate LED.
A small delay between reads will reduce flickering.

What to Turn In
1. Please indicate how many hours you spent on this lab. This will be helpful for
calibrating the workload for next time the course is taught.
2. Schematic of the circuit on your breadboard, showing all components and which
Nucleo pins are connected.
3. C code for your digital level.
4. Does your program work? Can you tilt the accelerometer and move the LED
bubble across the array in both axes as expected and reach every dot in the 7x7
array?
Please indicate any bugs you found in this lab manual, or any suggestions you
would have to improve the lab.

Page 2 of 2

You might also like