Pages

Friday, September 9, 2022

An easy gesture controller

For an index to all my stories click this text

As you might know by now I wrote, up to now, two books. A book about the ESP32 and a book about the Raspberry Pi Pico. You can find links to these books at the bottom of this page.

In these books I described a tilt sensor called the SW-520D. Lets first look at how it functions inside.



As you can see the way this sensor works is fairly straightforward. On the inside on one side of the sesor there are 2 contacts. And there are 2 metal balls inside. When the sensor is in the upright position the balls shorten the contacts. At an angle the balls still shorten the contacts. When horizontally the balls might shorten the contacts or the contacts are open. And when the sensor is at a down angle there certainly will be no contacts shortened.

You can use this sensor as a switch. You could use it for example as a means to test wether a box is upright or upside down.

Then I had an idea. How about using this sensor to control all kinds of appliences and even as a remote controller for a car. To achieve this you'll need multiple SW-520D's arranged in a particular way. I'll show you the fundamental setup here:





I'll bet you get the idea. Put this on a breadboard and lift the breadboard at an angle downwards and the top sensor will make contact. Lift the breadboard upwards and the bottom sensor will make contact etc etc etc.

So let's put this on a breadboard and attach some leds so the sensors to check wether this works.




The above breadboard setup shows you how to attach all items. The only thing you need to supply externally is power. I use a breadboard connector for a USB power supply or powerbank but you could attach batteries.
Just make sure you put the SW520's in the right way on the breadboard. Mind where the sensor makes the contacts and put the it the opposite way on the opposite sites.




Here is an example on how this looks in real life.




And here a short movie that demonstrates how this functions. As I am filming and controlling the setup at the same time it is not the best demo but it gives you a good hint on how this works in real life.

When I build this I immediately had some ideas and I will work them out and show them in future stories. In the mean time I will give you a real example here.

Gesture controlled MP3 player.

Remember the MP3 player I described in this article:
https://lucstechblog.blogspot.com/2019/05/mp3-player-stand-alone.html

Well what I did is to replace the buttons with two SW520D tilt sensors.




Re-read the above mentioned story about this MP3 player and adjust the breadboard like this. Now you can control jumping to the next or previous number on the SD card by a quick forward or backwards nod. Keeping the board in an upward or downward angle will set the volume louder or softer.

The setup with 4 sensors is ideal for building some gesture controlled projects. And I will be devellopping them for future stories. So keep on coming back.

Till next time
Have fun

Luc Volders