Arduino makes 2D Level

This is a project for Arduino to make a 2D Level, aimed at beginners.

Arduino draws a circle on an LED Matrix that moves around according to readings from a 2D Accelerometer.

* Learn how to draw a circle using simple Math’s
* Learn how to use the LOL shield for the Arduino
* Learn how an accelerometer works

Arduino 2D Level

Step 1: What you need

You will need:
* Arduino UNO
* LOL shieldย ย  (
* Accelerometer (
* Breadboard for wiring up e.g. (
* Some Wires

Step 2: Wire it up

Attach the LOL shield to the Arduino.

Wire the Accelerometer as follows:
X => A0
Y => A1
Z => N/Cย  (Not Connected)

Note: The LOL shield does not come with Headers (as shown in the picture), attached to the topside.

I bought some here:

Step 3: Install the LOL Shield Libraries

Install the Arduino libraries for the LOL shield if you don’t have them already. You can get the link to them from this page:

Step 4: Let’s Start With a Circle

We’ll start by drawing a circle.
Arduino 2D Level connection
This circle will eventually move around as we tilt the device. But first things first….

We’ll illuminate individual pixels on the LOL shield using the LOL library command:

LedSign::Set(x, y , 1);

where x and y are the coordinates on the shield of the LED we wish to illuminate

Our job is to figure out how to calculate the x,yย  values that make a circle.

In Pseudo code we do it like this to draw just one quarter (Quadrant) of the circle:

for x = 0 to RADIUS
y=f(x);ย ย ย ย  // This means y is some function of x. We haven’t said what function yet

So what’s the function?

r^2 = x^2 + y^2

where x^2 means “x squared” or “x to the power of 2”

We know x because it’s the for loop iterator;
We know r because it’s the radius,
So we re-arrange to find y

y = sqrt(r^2 – x^2)ย ย ย  // sqrt() means square-root

When you code it up you get a circle as shown in the picture.

[box color=”#985D00″ bg=”#FFF8CB” font=”verdana” fontsize=”14 ” radius=”20 ” border=”#985D12″ float=”right” head=”Major Components in Project” headbg=”#FFEB70″ headcolor=”#985D00″]Arduino UNO
* LOL shield
* Accelerometer[/box]


For more detail: Arduino makes 2D Level


About The Author

Scroll to Top