# Pendulum wave using the LOL shield

I have had a lol shield laying around for quite a while now and never really used it beyond the example sketches. It’s a great little glowy shield, especially as I love anything involving leds.

So I decided to write up a quick sketch to make something interesting to light up my desk as I work. Being a physicist I decided on a pendulum wave. It’s a nice demonstration of simple harmonic motion and pretty hypnotic to watch. Here’s a nice youtube video of a real one in action: Pendulum Wave.

For my sketch, each vertical column of leds represents my mass on a spring, and each column will have a shorter string. This is simply modelled and a nice derivation is given here. So it was just a quick job of writing up a sketch and here we go! Enjoy the video (apologies for the poor quality). Here’s the sketch if you want to have a go:

#include <Charliplexing.h>

void setup() {
LedSign::Init(); //Initilizes the LoL Shield
}

int p = 0, Hled;
int N = 50; // N is the number of oscillations individual oscillations on the first pendulum until the whole wave repeats
int period = 20000; // each time step is an interger incremented each loop
double amplitude; // amplitude of each pendulum colomn

void loop() {

for(int x = 0; x < 14; x++){
for(int y = 0; y < 9; y++){
if(y == Hled[x]){
LedSign::Set(x,y,1);
}
else{
LedSign::Set(x,y,0);
}
}

for(int z = 0; z < 15; z++){
amplitude[z] = (4.5*(0.85+cos((2*3.141*(N+z))/(period)*p)))+0.5; // calculates the amplitude of each colomn
Hled[z] = int(amplitude[z]);
}
p++;

}
}