Getting there...

2009-Sep-16, Wednesday 10:33 pm
[personal profile] chebe
The physical construction of my Arduino Lilypad glove is almost complete. Just have to tighten the fit, finish a few edges. I was going to line, decorate, and all that jazz, but feel it's a bit unnecessary for this project. I am getting usable information in, and just have to decide what way I want to use that information, as in, how I want the lights to behave in relation to movement. Here's the glove:



Here I've marked the positive and negative threads/currents in red and blue respectively. I wasn't sure this was going to work, and I'm certainly not sure if it's a good idea, but I wanted to try and balance out the look of the glove, and it all worked, so I thought why not.



So what exactly are all those components? Why, I'm glad you asked!


Arduino Lilypad controller:



Controls the behaviour of your circuit, it's where you load your program onto. Has + (positive) and - (negative) terminals on the left. You connect these to the respective + and - terminals of your (invariably battery) power supply. The petals numbered 0 to 13 are for digital inputs and outputs. (Although you can use them for analog communication as well as I have done here.) And the petals numbered a0 to a5 are for analog inputs and outputs. On the board there's also a reset button, a couple of LEDs, and the prong-like connector for the cable to your computer.


3-axes accelerometer:



This is an analog sensor. It gives you feedback about spatial orientation and basic motion sensing. Also has + and - terminals. (You may need a magnifying glass to see the markings if you're anything like me. Not seeing these markings held me up for ages, as I was getting seemingly meaningless and random data as the co-ords.) And three petals, x, y, and z (each with a little arrow indicating it's direction). X, y, and z are all analog outputs. They will give you a value in the range of 0 to 1023, which are not absolute values. The value is representative of how much current is getting through, so the number between 0 and 1023 marks a value somewhere between about 0 and 3.3V. In order to relate the output to usable co-ordinates and angles you'll need to do the experiments and maths yourself. Although there is a helpful table at the bottom of this tutorial you can use as a guide.


RGB LED:



This is an actuator, because it actually does something. It makes light made up of three lights, a red, a blue, and a green. When all lights are on full you see white light. This component only has a + terminal, and a petal for each colour. Here the RGB petals take an analog input, which is in the range of 0 to 255, and maps very nicely to colour values. However just taking the accelerometer data in, assigning one value to each colour, and dividing by 4 isn't enough. The colours all end up looking mostly the same. Some clever fading and smoothing is going to have to occur, I just don't know what exactly yet.


Things I learned:

- Analog sensors give you a value between 0 and 1023, which represents the level of current flowing through it. Not anything useful like an absolute temperature, sound level, or angle. You have to work these things out yourself, with a thermometer or other measurement device in hand, and seeing what the values correspond to.

- Analog actuators take values between 0 and 255, which I assume represents a level of current?, but that doesn't really matter much. The easiest way to get from sensor data to usable actuator data is to simply divide by 4. This however, doesn't always give you the behaviour you desire.

- Accelerometers also require + and - lines. If you can't see the markings you need a magnifying glass. It will still seem to work without them hooked up, but you'll get somewhat random data that if plotted looks like a soft wave, sitting at 0 for a bit then increasing over a few values to 1023, where it will sit for a bit before descending over a few values to 0, and repeating.

- The language you use to program the Arduino is called Processing.

- Getting data from the Serial object is quite simple. For the regular Arduino if you specify the transfer rate Serial.begin(9600) it comes through on baud 9600. However, for some reason the Lilypad when set at 9600 comes in at 19200. If set at 4800 comes in at 9600. Don't know why. Yet.