praxworld.com Electronics, music, electronic music! general geekery

12Mar/120

Middle Aged Engineering Grum-P-Lab: connect and read sensor input


When I left off from Part 1, I had plugged the Teensy into the computer and loaded the flash program to make sure it works. The next phase involves loading Firmata onto the Teensy, and getting some sensor input into MaxMSP. Note that Firmata and MaxMSP are just two of many software possibilities. Other programs that are great for doing stuff with sensors include the free open-source PureData, and Processing applications.

To load Firmata onto Teensy, download and install the Teensy loader if you haven't already done so. Then, pick up the special Teensy version of Firmata from here. Follow the instructions for loading Firmata onto the Teensy and you're good to go.

For my first sensor I'm going with the pressure sensitive resistance pad. When you press on it, the resistance goes up! I have soldered it to the end of a 3.5mm male cable. One lead of the pressure pad is connected to the ground wire of the 3.5mm cable, and one to the positive wire (tip). You can ignore polarity for the pressure pad. This diagram shows the circuit (Teensy on the left, audio breakout on the right, pressure pad assembly is not shown - it's plugged into the breakout):

  • +5V to TIP
  • GND to GND (10k ohm resistor)
  • A0 (38) to GND

If you omit the +5V line all you'll get is noise. When I load the Max patcher and press the pressure pad, I can get a good signal. Woo-hoo! This could be set up to go to a pitch bender, bit crusher, purple spotlight, vacuum cleaner, or whatever. You can alter the response of the pressure sensor by placing other thin materials on top of it (if you're building it into something you will probably do this anyway). My feeling was that it tends to dampen the response a bit. This is good since at light pressure the reading is a bit jittery. Also you can play with the resistance on the +5V to change the high limit. 120k ohms worked for me but your mileage may vary. If you are building this into something a trimmer resistor might not be a bad idea here.

Here is a screenshot of the Max patcher. You can set it to print the analog values, and the other part flashes LED 6 for an easy way to make sure your serial connection is working.

And the code:


----------begin_max5_patcher----------
1943.3oc4assiaaCD8YGf9OPXzGRK13kT2ceKn.EH.sHEH8sf.CZIZuLUVzP
hx6tMn+6kWjjkjkrobj0t.MHQaBuN7vyLblgLe6Gdyr4qYOQxlC9EvmAyl8M
QIyTkIKYVYAyluC+TXLNS0v46HYY3sj42UTIm7DWUgyhf.q.jcUMaXI7D7Nh
p12mRwwUUkjuilDS3pgzprTZjpor0e8cdN0aKKmW1XT8QO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b11qkN3VyrL1qEBwcO9n
.z6aor3xHQP0SSxeYGW7fdhZdpTAL0VAsDrNQwLng9VeVwap91gFYGZict8Y
rbIe4pWVvBld4x50ob4YjbI++fPsCte8HXxa0ZhQLWiDL48DM0BFzDAy9EPm
z2DAywd5ELWirhM8br1XQOHl0jKX1dFwwldDqMs9LB1zZGy1HsRqo2bgkQak
SOES93UpuG0ibM8lwLxtuyzeDNxnMROqWoBV686AJXENy15wMnjo1Opg1Ong
SdLCpQU74+7F22IN
-----------end_max5_patcher-----------
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment

No trackbacks yet.