Midi Controlling Leggings

by mobomusic in Circuits > Wearables

973 Views, 2 Favorites, 0 Comments

Midi Controlling Leggings

Screen Shot 2015-12-13 at 11.00.54 AM.png

Have you every wanted to control music or visuals with your leggings? If you have ever wanted to get away from the constraints of using a midi keyboard or pushing buttons on your computer to manipulate your audio or visuals this project is for you.

Materials:

For this project you will need:

  • 1 pair of leggings
  • 1 soft potentiometer
  • 1 10k resistor
  • 1 Arduino Fio
  • FTDI Programmer with male pins out
  • Mirco USB serial cord to program arduino
  • 1 3.3V lithium battery
  • 2 Xbee S1
  • 1 Xbee Explorer USB Dongle
  • Rainbow wire
  • Small perf board
  • Soldering Iron
  • Solder
  • Heat Shrink
  • Bread Board
  • Jumper Cables

Hooking Up Your Circuit:

Screen Shot 2015-12-10 at 9.14.51 AM.png

Get out your bread board and lets hook up your sensor!

SparkFun’s SIK guide (found here: https://learn.sparkfun.com/tutorials/sik-experiment-guide-for-arduino---v32/all#experiment-10-reading-a-soft-potentiometer) has a good example of how to hook up your soft potentiometer in circuit 10 (you can ignore the LED part if you want).

The soft potentiometer functions similarly to a regular potentiometer. There are 3 pins. The two outer pins of the sensor control the resistance and are hooked up to ground and power. The two pins are interchangeable and depending which pin is connected to ground and which to power will effect the direction in which your sensor will work.

The middle pin is the pin you connect to the analog input, in our case on the Arduino Fio. Make sure you have a 10K resistor running to ground from the middle pin as well otherwise your values will not be linear.

*When testing the circuit this may be easier to test with an Arduino Uno, but if you don’t have one you can use the Fio.*

Programming the Arduino Fio:

FTDIdriver.jpg
IMG_0999.JPG

To program the Arduino Fio you will need to download and install the FTDI drivers, which you can do here: http://www.ftdichip.com/FTDrivers.htm

Also if you do not have the Arduino IDE this would be a good time to download that as well form here: https://www.arduino.cc/en/Main/Software

To program the Fio using the FTDI programmer, plug the micro USB into the input on the driver and plug it into your computer. Make sure the Arduino Fio is selected under Tools > Board > Arduino Fio. Then make sure that your serial port is selected in Tools > Serial Port (this port is the one that is not your bluetooth port). From this point you will be able to line the male pins of the programmer up with where the Fio says FTDI. You should see a light on the programmer and on the Fio blink if it is plugged in correctly.

You can now program your Fio!

Testing the Xbees:

XBee PCB_01.jpg

To test that the Xbees are working we will need to plug them in and upload a basic code.

First plug the Xbees into the Fio and the USB Xbee Explorer. Carefully notice the direction in which you plug them in. You shouldn’t have to do any configuration for them if you have received them right out of the box, but if you think you do need to configure them, or you would like more info, you can look to these resources:

https://learn.sparkfun.com/tutorials/exploring-xbees-and-xctu https://www.arduino.cc/en/Guide/ArduinoWirelessShieldS2

Most Xbees out of the box start at a 9600 baud rate, but if you are having issues you may also want to reconfigure the baud rate or check it.

To do a basic test to make sure the Xbees are working open the code attached. Make sure the baud rate is the same rate as what your Xbees are configured to. This is the value in the Serial.begin() parenthesis. Once you have checked this hit the check mark at the top of the IDE to compile the code. Once the FTDI programmer is correctly plugged into the Fio hit the arrow next to the check mark in your IDE and the code should load on to your Fio.

Once the code is uploaded, remove the programmer and plug the 3.3V battery into the Fio. Turn on your Fio and plug the Xbee Explorer into your USB port. Open your serial monitor in the arduino IDE by going under Tools. Make sure the baud rate is the same as your Xbees. In the small white bar you can type 'a' and this should turn the onboard LED on the Fio on. If you type 'b' the light should go off. If this works that means your Xbees are communicating! If not first try closing out of the Arduino IDE and reopening it. If it still does not work consult the links above for troubleshooting.

Downloads

Putting Everything Together:

Now that you know the Xbees are working properly the next step is to make sure the circuit is working with everything.

Upload the code attached to your Fio. Connect ground to ground and power to power from the circuit to the Fio. Finally connect the middle pin to the a0 hole on the Fio. You can wrap the end of the wire or jumper cable around the holes on the Fio for testing purposes. We will solder it all together once we know it all works.

Once all of this is set up. Plug the battery in and turn on the Fio. Open up your serial monitor again and this time every time you put pressure on the soft potentiometer you should see a string of numbers. They should move between 0 and 1023 as you move your finger along the length of the potentiometer. If this works we can now work on getting the circuit to communicate with Max MSP.

Downloads

Communicating With Max MSP:

Screen Shot 2015-12-13 at 11.03.55 AM.png

The next step is to get your Fio communicating with Max MSP.

First upload the code attached to your Arduino Fio. This code will read the sensor values and then print it to Max MSP. Once this code is uploaded make sure to close Arduino before opening Max MSP.

Copy the text below and then go into Max MSP and under File select New From Clipboard. This should allow you to open a patch that lets you accept Serial Data in and then scales that data to a value between 0 and 127, the range of MIDI cc data. Make sure the baud rate in the serial object matches the baud rate you are using, select the correct serial port and then toggle the serial translator on (the big toggle at the top of the patch).

Now if everything is working you should see the message box underneath the p datahandler change values relating to pressure on the soft potentiometer.

From here all you have to do is select a Midi Port and go into your favorite DAW and midi map your control value to whatever knob or control you wish to control!

----------begin_max5_patcher---------- 2748.3oc6cszjihiD9rqeED9b0cnGHdr2lclC6Fw1arQzwdZhIp.aT4hYvfW Pt6pmIl+6qPRfE1FPfALS0Uevtj.LY9oTox7SO5+3gUq2j9JMes0ey5msVs5 OdX0JQUEUrRUd058AutMNHWbaqSneMcyut9Q4kXzWYhp2xhSOxJqN439njXJ S7HXUk4ruESE2r1swenx6Cnp8P.a6KQI6dJitkIEMaaxGAOZY66V7EzQTBg9 Hv5WTOTTn3WlKZe.BVWT2e9vCEe73soWwoAgaBR1cUMCZnlUdexpXe6.UpVq E+xU5vUTbhGnPUwHXwWNf1za+gn1aS2umlvtPu+wWRSyoVeJJLx5PZF6lz+x V1mSSX4Q+t3VgbsnY81w2SzfaKzXnsyEJ9lia1HeovKgB20Zuwjf8Rg6GSOl EQyFj0ww8a3O4s.Bn1AgKrMV+nA1GpNFJ6CRq1GdWET9grnf30UugLd8LZ1S zj.E7BF.bcjaSc7lPK70PKbynUTgMrDzNAXAwwoeMLKXWM2KYzbtEe.KJMQC Iw9XI3IL0fDg8GBqCkL5dkqx0+v+05m9We15yeKg8hEr3s9XwG+aJ6qoY+l0 mo447edsq7bV5dqOE750pB0tK.DQuqvUDLcMpgNDPxX2D2f+x8bGFQIOmd0F eTO8WZZiuQtP8b+Hg2EgbY65IXh32RejA.RaNxX71j66XGDagJCJ+7ZJtyfF yLTy0w3pbOyG2kYhmOa.P9U4mWMh.7LY8mSis.2joeeGkPFaRGcAJGkPZIfc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JKMk8xG9mI7N1bn5C+GwhQTcBAd55eJMjtu8CspxsU sI6oEh6bZvceOuhj9iPlbH3MlmVQMehccWNwhPZyPKo886zLMari5IqauNt7 5FmjVKtsdtNQlqy0IUPOA7bB..KOdVJfQYztZSesG1GAcJl4ZjGxG4nlCafi 8kSh8YSvYulX6GM63eBZK8lY61VSfwKb.wCWmoHYCx4IMnZVZesG1PdBN01i pWlhvkA6eg8gohimAhS8kvyUDmy2ouDww8GVctZpU5zKZzTfyvpF1099yFf5 Xf3X2O7rHCghCbV4YtIr7um.vjXh0Y8zc6V7IdhkLns77PlfsqJMEZf23i+R HWcxmV82Sgv6ZhvCz4Wxfdip8ZublnzKMEZfIl+j9Z+iEDY4RJ23UpBSg7aa RGfAI9P.RS9Ekl.Ev1H2gt8SCP7b.HECdpVh+x0BUsRPGU1o9Wojbj3RSOj+ zo4vwsoSIxJU01Fpo3pRk+WHgm2UJg70axmJEe7MYwmZolbwGQLP9cACpOGh n6yPT5doAEGdq8wscoLKOX9Pd3pR2KM.Mrl.oBnhBbxT.foi6zil.DV31Sc7 UbpvTH+FH9dCKJbfudT3foQ9qOogFcxAMoQgCwl3TbFkGnI3Cd9jGS5tLrvb bTqrXeswCqJoNULsqJME1hF.018b7jhIlfTI4p3gDklHEnqFG7fFMor4.nGr RUIjZtiISaaSmiybaFdZk5TAjr4b1tPnP1Oa2Gb1NO3xccPy63fy2sA727e9 v+GPN0ik6 -----------end_max5_patcher-----------

Downloads

Leggings and Soldering:

IMG_1001.JPG
IMG_1003.JPG

The last piece is attaching the sensor to your leggings!

For attaching the soft potentiometer into the leggings I suggest trying the leggings on and deciding on where you would like the soft potentiometer to be. Use tape to mark those spots.

Once they are off of you take the three pins of the soft pot and stick them through the fabric of the leggings. Pull off three wires from your rainbow wire and stick a little strip of heat shrink on the ends you are going to solder onto the soft pot. Solder the wire onto the soft pot. Now try the leggings back on to make sure the sensor is still where you would like it to be. If you are happy with it test to make sure the circuit is still working and then we can move on.

Next solder the wire and the resistor onto a small perf board connecting everything the same way as on the breadboard. After that solder the 3 wires to their respective solder holes on the Fio. Test everything again. If it all still works you can use a heat gun to shrink the heat shrink around the pin joints, put the leggings back on, and take off the adhesive backing of the soft potentiometer and tape the sensor to the leggings.

Sew a little pocket into the inside of the leggings as a place to now put the Fio and the small perf board.

Once this is all set up you are ready to control your music with your leggings! Have fun!