Vernier Software and Technology
Vernier Software & Technology
Arduino and Vernier Sensors

Controlling a RGB LED with a 3-Axis Accelerometer

This is a simple, but visually interesting, project. Use a Vernier 3-Axis Accelerometer connected to three BTA sockets. Continuously monitor the voltage of each of these three accelerometers and use the readings to control the brightness of the red, green, and blue LED. Note that the signal from an accelerometer changes depending on how it is oriented. The highest voltage is produced when the arrow on the accelerometer points up and the lowest when the accelerometer arrow points down. With this sketch running, the color of the RGB LED will change to almost any color you want, depending on how you hold the Accelerometer.

The sketch to use for this project is called Vernier3DAAutoscale. It is written with a 15-second calibration period when it first runs. Start the program, the LED will flash once. For the first 15 seconds, gently rotate the 3D Accelerometer so that all three arrows on it point in every direction. The program will take readings which will be used to “calibrate” the brightness ranges of the three LEDs. After the 10 second period, the LED will flash again and from then on, the color will change with accelerometer orientation. If you choose not to calibrate the program simply leave the unit alone through this initial 15 seconds and it will use default values we have provided.

Note that this project requires a RGB LED connected to three digital output lines. It also is the only time we use a third BTA socket. You can still use this sketch with just two BTA sockets. Plug in the X and Y acceleration connectors, and experiment.


Contents

Introduction

Vernier Engineering Contest

Vernier recognizes instructors for creative uses of Vernier sensors to introduce engineering concepts and/or practices. Vernier Engineering Award »

Go to top