Categories
TUTORIALS

Vibrations to Light: Use a Piezo Element to Control an LED Strip

Hello Arduino world!

At the end of this tutorial you will be able to use a piezo element to activate lights on an LED strip.

Before we begin, let’s better understand what is occurring with piezoelectric sensors. Piezoelectric sensors utilize the idea that everything gives off vibrations and shocks when it moves, and therefore, this vibration can be sensed and harvested to power other elements.

This tutorial focuses on the larger idea that vibrations from trains could be used to power installations around cities, if the installation is close enough to the source. Some of these installations may use LED lights or strips as indicators, which is where this tutorial comes in.

For now, we’ll just look at a small portion of this idea – how readings from the piezo element can control the lights on the LED strip.

Let’s begin!

Materials Needed:

  1. Arduino Uno board
  2. Breadboard
  3. 0M ohm resistor
  4. Piezo Element
  5. 10 Segment LED Bar Graph
  6. 10 330-ohm resistors
  7. Alligator clips
  8. Jumper wires
  9. Aluminum foil
  10. Toy train

Wiring the Board:

Before creating the circuit, it is important to understand how much electrical current is needed for each part to operate and how much resistance is required. The piezo element requires a 1.0M ohm resistor compared to the LED lights which require much less, 330 ohms. In fact, the 330-ohm resistors provide more resistance than necessary for the LED strip, but it is always safer to use a higher ohm resistor than what is required rather than a lower ohm resistor if that is what you have on hand. If you would like to learn more about how to calculate the necessary resistance, here is a helpful resource.

The most important pin connection in this circuit is connecting the piezo element’s red wire to pin A0. This is an analog pin, which allows the information from the piezo element to be sent to the computer. The breadboard diagram below will help you make sure that connection is being made, along with setting up the LED strips. Because the LED strip is composed of 10 individual lights, each one needs to be connected to a pin and a resistor is used to ground each one.

You may notice that the piezo element’s wires are much thinner and shorter than the other jumper wires. While you can connect the piezo directly to the breadboard with those wires, I found that they were too short for it to lay flat on the table. To get around this, I made a connection between leading jumper wires and the piezo with alligator clips.

In the diagram above, the jumper wire is connecting pin A0 to breadboard location D5. I then put in another wire in E5 that leads to the piezo element’s red wire. If you try to just connect the piezo element’s wire to the jumper wire with the alligator clips, the piezo element’s wire will fall out because it is too thin. Wrap the two ends in aluminum foil and use the alligator clip to hold the connection in place. Repeat this with a wire leading from the piezo element’s black wire to the ground on the breadboard.

After you wire your breadboard, I suggest tracing the circuit with your finger to double check all the wiring is done correctly before moving on to the next steps.

The Code:

The code below walks through how to send data from the piezo element to your computer. By using the serial monitor window, appropriate thresholds can be set to turn on and off segments of the LED strip.

Copy and paste this code into a blank sketch and upload to your board. While I use a train to simulate vibrations and shocks, you can test whether the piezo element is working just by tapping on the piezo element pad.  Enjoy!

Leave a Reply

Your email address will not be published. Required fields are marked *