Did I have you at DDR? Dance Dance Revolution is one of those games that has its very loyal audience, with hours wasted in local arcades breaking records and myths about rhythm and grace simultaneously. Search Youtube for DDR, and it will take you down the most amazing internet rabbit hole, across generations, and across countries and oceans.
A DDR style mat can be easily made by making a series of pressure sensors and some LEDs. Pressure on the sensor can be detected by a microprocessor such as an Arduino, SparkCore, Galielo, and the leds can be used to give visual cues of the sequence or light up when its been stepped on.
You can go and fork out the cash for some pressure sensors which typically range in price from 7- 12 bucks. These sensors will give you a higher level of fidelity and are better for applications that require more fidelity in weight for example. We are going to make our own pressure sensors from Velostat which is a pressure-sensitive conductive material. If you add a bit of conductive thread to it, you can capture the analog values to determine pressure, and boom – you got your own pressure sensors perfect for a DDR mat, a whoopie cushion, even a smart coaster.
Making a Pressure Sensor from Velostat and Conductive Thread
This is the easiest part of this project by far. You will need the following materials to create your own pressure sensor:
Reading the Analog Value
You will need to calibrate the sensor. This often means reading the values and determining the value range. For my sensor, with no pressure, I was reading about 120 and up. For a full press, it was somewhere under 20. To capture an analog pin, you will need to read it’s value using the analogRead method in most microcontrollers.
Using the Data From the REST API for the SparkCore
If you are using Arduino, you will need to think about how you can access that data elsewhere or share it. With an Arduino Mega, you could use low level sockets for example. You could store the data in a database. You could use web sockets, or something like Spacebrew with Processing.
As I am using the SparkCore...
Using the Data In Unity2D
I followed a basic tutorial to make a Flappy Bird clone - probably #546,335 clone of this game to be exact. Instead of pushing the spacebar, I decided to use my sensor. To capture data from the api in Unity I had to pull down the JSONObject library available from the Asset Store in Unity.. I could then use the WWWW class in Unity to retrieve the data. Here is an example of getting the data from the api, which I do in the Plane script:
Using the Data in BabylonJS
I took one of the basic particle examples from BabylonJS, and I showed how to capture the data from the SparkCore API to incorporate it. If you press the sensor, you’ll start the particle system. Imagine making a few sensors where if you walked in difference places, you’d trigger explosions ( land mines) for example. Again, I just captured and polled the REST API on a regular interval using jQuery:
That should give you something fun to build for the holidays or when you're snowed in... :)
Comments have been closed since this content was published more than 30 days ago, but if you'd like to send us feedback you can Contact Us.