Tis The Season for Inventing, Tis the Season for Giving, Tis the Season for Arduinos

This next video is a demo of the packaged version of one of the circuits shown in the above video. It had to wait until my Cel Robox 3D printer arrived so I could print the housing.

There are more videos about it and the printer in my road test review here:


Alright, in the spirit of the season here is some fun you can have with an arduino.

This demo is going to use lots of technology, but it will only take a few minutes so that people of all skill levels can try these concepts and create their own fun projects.

We are going to use an arduino to convert a low-cost sensor output into some useful activity.

The sensor

This project uses a piezo electric disk sensor made from ziconium titanate and brass. It can also be an actuator if it is driven. I won't be talking much about it as an actuator in this video, but I show an example to demonstrate one of their primary actuator applications: A piezo buzzer hooked up to a 9 volt battery in a kind of starter pistol I built for one of my old robots....When I pull the trigger switch, an oscillator causes the disk to vibrate and emit an audible tone.

The basic disks cost about 25 cents each. As a sensor it will generate a charge or voltage when it is strained. A simplified way to think of the piezo electric effect is when the piezo electric cystaline material is bent, the side that is in compression has less "room" for electrons and they get squeezed over to the side that is stretched in tension where there is more room. Generically these disks are called piezo benders.

This charge separation due to physical bending can result in pretty high voltages without any external power supply, and in fact this effect is used in many igniters to generate voltages high enough to cause a spark.

This little disk will generate 80-100 volts with a simple tap, which hardly bends the material at all. In the video it is hooked directly up to an oscilloscope and when I tap it .... the captured waveform is about 100 volts. Note that the wave form can go positive or negative depending on which way the disk is deformed.

To demonstrate energy harvesting with this technology I have hooked up 2 LEDs in parallel but reversed so both polarities will be used to generate light. A single tap generates enough current and light to be visible to the eye, but I will supply the vibration from an old electric razor to make it more obvious.

Okay but we want to use it as a sensor for an arduino and 100 volts will damage our arduino so we need to prevent such high voltages from reaching the MCU.

Here I am using a 33Kohm resistor to limit the current and clamping diodes to prevent the signal from exceeding the power supply. One diode prevents the signal from going negative and the other diode prevents the signal from exceeding 5 volts.

Okay, enough about the sensor for now, lets talk about the arduino.

This is an arduino Pro Micro which is software compatible with an arduino leonardo but I like this smaller Pro Micro form factor. The CPU of the Pro Micro or Leonardo has a built-in USB port that we are going to program to emulate a USB mouse. In particular when pin 3 goes low, the ardino will be programmed to initiate a left mouse button click. A short sketch to do this is published at the end of the article.

To hook up the sensor, we connect the signal to pin 3, the sensor ground to a GND pin and the clamp diode to the VCC pin.



Now if I plug the arduino into a PC using a USB cable, the arduino will automatically get enumerated as a standard human interface device (HID) of the mouse variety.

When the sensor is disturbed the arduino will flash its green LED and generate a left mouse click.

So what can a left mouse click do - well it can activate or interact with any program. Suppose we just want to count events without doing any programming.... we can use the built-in Windows calculator and use it to count sensor events. First click on one plus then leave the mouse pointer on the equals sign. Now whenever an event is detected it adds one to the total. By the way, you can wire this sensor into a cheap calculator button and have it counting events the same way. The numbers are a bit small to see in this demo so I will close the calculator and start a big digit counter which I programmed in Visual Basic 6 to perform simple up or down counting. The source code for this counter is only 3 lines and is shown below.

You could use this technology to create an electronic drum pad. The video shows an example using the sensor to play a sample snare drum sound with the VLC Media Player. It could of course play any other sound effect in response to an event.

Another use might be to detect when a target is hit.

Okay that is cool, the sensor can detect taps and make the PC respond, but you could do pretty much the same thing with the arduino and a switch to trigger it.

This sensor configuration is not sensitive enough to pick up near-by vibrations like a ball bouncing, but we can detect much smaller events if we hook up a little amplifier that runs off USB power. The circuit in the video has an amplifier, a one-shot and an LED to indicate sensor activity and it is much more sensitive to small vibrations. This circuit was originally designed to detect the movement of insects, so it can be adjusted to be very sensitive. It will easily detect a ping-pong ball bouncing nearby and trigger the LED.

The output from this module only needs to connect to ground and the signal pin(3).

Lets see how sensitive the sensor is now. If I drop a piece of paper from 1 inch onto the sensor it triggers. If I drop a surface mount resistor on the sensor it triggers. If I drop a business card beside the sensor it triggers. The bottom line is you can detect a lot of different types of event with this sensor. You could invent games where sensitive detection of movement of objects is required.

So how else can we use this? I will use the sensor to trigger various sound files. How about detecting when presents under the tree are being tampered with? I'll set up a sound file and try to move the gift and see if I get busted.

Can I raid the cookie jar?

You can see how easy it is to use a cheap sensor and a small arduino to control a PC. The whole system can be set up in minutes. It may seem quick and easy to do some interesting things, but underneath it all is a wide range of technology - sensors, analog circuitry, digital circuitry, microcontrollers,  firmware and software. This demonstration was intended to show that complex technology does not necessarily need a huge learning curve to start having fun.

Tis the season for inventing and giving so there you have it - a gift of ideas, knowledge and fun.

The video wraps up with a somewhat appropriate song excerpt.

Here is an older video I did showing a ping pong ball sensor:

Ping Pong Sensor


The full song from the top video can be found here:



You might have to be Canadian to get the lyrics though...


arduino mouse clicker sketch



Mouse Clicker Sketch

by Doug Wong   2014

pulling pin 3 low triggers a left mouse click

pin 2 enables mouse mode



void setup()


  pinMode(2, INPUT);        // input to put device into mouse mode

  digitalWrite(2,HIGH); // set an internal pullup so the input is normall high

  pinMode(3, INPUT);        // input to detect sensor activity

  digitalWrite(3,HIGH); // set internal pullup so input is normally high

  pinMode(13, OUTPUT);      // set pin to be an output so it controls the LED

  digitalWrite(13, LOW);    // set the LED off



void loop()


  if(digitalRead(2) == LOW) // if pin 2 is low then start mouse mode


    Mouse.begin(); // start mouse mode

    if(digitalRead(3) == LOW) // if sensor input is low generate mouse click


      Mouse.click();                 // send left mouse click to PC

      digitalWrite(13, HIGH); // set the LED on

      delay(100);                     // wait .1 second before turning LED off

      digitalWrite(13, LOW); // set the LED off

      delay(1000); // wait a second before looking for more sensor activity



  else                      // if pin 2 is high end mouse mode


    Mouse.end();            // end mouse mode




Visual Basic Mouse Click Counter Program


' Mouse Click Counter

' by Doug Wong

' 2014


Private Sub Clear_Click()

    counter.Text = "0"                                        ' clear the counter

End Sub


Private Sub countdown_Click()

    counter.Text = Str(Val(counter.Text - 1))   'decrement the counter

End Sub


Private Sub countup_Click()

    counter.Text = Str(Val(counter.Text + 1))   ' increment the counter

  End Sub