Arduino + Wav Shield + PulseSensor
I need to update the sketch. The way it is, it sometimes misses a beat.
Arduino + Wav Shield + PulseSensor
I need to update the sketch. The way it is, it sometimes misses a beat.
After freezing my ass off at Burning Man last year, and after discovering EL wire at Burning Man, I decided I wanted to make myself some kind of incredibly warm, pimped out coat which glowed. But rather than siimply glow, I wanted it to change colors in some dynamic way. I settled on the idea of having it change colors based on which direction I was facing.
This early version used this EL Sequencer from Sparkfun to turn on different strands of EL wire based on the heading returned by a HMC6352 Compass Module.
I ended up abandoning this approach and instead using an LED strip which could blend seamlessly from one color to another.
I’m posting this mainly so I can link to this tutorial on using the Sparkfun EL Sequencer. It’s probably the worst documented thing I’ve ever bought, and without the tutorial, I never would have gotten it working. That said, the sequencer works well once you decipher it via that tutorial.
Also for reference- I learned how to hook up the HMC6352 Compass Module by following this useful post.
In the video above, the EL Sequencer was programmed with the following sketch:
//All this does is read the heading from HMC6352 and spit it out via serial #include <Wire.h> int HMC6352SlaveAddress = 0x42; int HMC6352ReadAddress = 0x41; //"A" in hex, A command is: #include <avr/io.h> #include <avr/interrupt.h> #include <util/delay.h> // turn a given EL wire segment on or off. 'num' is between 0 and 7, corresponding // to EL segments 'A' through 'H'. if 'value' is true, the segment will be lit. // if value is false, the segment will be dark. void elSegment(byte num, boolean value) { digitalWrite(num + 2, value ? HIGH : LOW); } int headingValue; void setup(){ // set up the EL wire segment pins byte i; for (i = 2; i < 10; i++) { pinMode(i, OUTPUT); digitalWrite(i, LOW); } // "The Wire library uses 7 bit addresses throughout. //If you have a datasheet or sample code that uses 8 bit address, //you'll want to drop the low bit (i.e. shift the value one bit to the right), //yielding an address between 0 and 127." HMC6352SlaveAddress = HMC6352SlaveAddress >> 1; // I know 0x42 is less than 127, but this is still required Serial.begin(9600); Wire.begin(); } void loop(){ //"Get Data. Compensate and Calculate New Heading" Wire.beginTransmission(HMC6352SlaveAddress); Wire.send(HMC6352ReadAddress); // The "Get Data" command Wire.endTransmission(); //time delays required by HMC6352 upon receipt of the command //Get Data. Compensate and Calculate New Heading : 6ms delay(6); Wire.requestFrom(HMC6352SlaveAddress, 2); //get the two data bytes, MSB and LSB //"The heading output data will be the value in tenths of degrees //from zero to 3599 and provided in binary format over the two bytes." byte MSB = Wire.receive(); byte LSB = Wire.receive(); float headingSum = (MSB << 8) + LSB; //(MSB / LSB sum) float headingInt = headingSum / 10; if (headingInt>337 && headingInt<361) { Serial.println(" North"); elSegment(0,true); elSegment(1,false); elSegment(2,false); elSegment(3,false); } else if (headingInt>0 && headingInt<23) { Serial.println("North"); elSegment(0,true); elSegment(1,false); elSegment(2,false); elSegment(3,false); } else if (headingInt>24 && headingInt<67) { Serial.println("North East"); elSegment(0,true); elSegment(1,true); elSegment(2,false); elSegment(3,false); } else if (headingInt>68 && headingInt<112) { Serial.println("East"); elSegment(0,false); elSegment(1,true); elSegment(2,false); elSegment(3,false); } else if (headingInt>113 && headingInt<157) { Serial.println("South East"); elSegment(0,false); elSegment(1,true); elSegment(2,true); elSegment(3,false); } else if (headingInt>158 && headingInt<202) { Serial.println("South"); elSegment(0,false); elSegment(1,false); elSegment(2,true); elSegment(3,false); } else if (headingInt>203 && headingInt<247) { Serial.println("South West"); elSegment(0,false); elSegment(1,false); elSegment(2,true); elSegment(3,true); } else if (headingInt>248 && headingInt<292) { Serial.println("West"); elSegment(0,false); elSegment(1,false); elSegment(2,false); elSegment(3,true); } else if (headingInt>293 && headingInt<336) { Serial.println("North West"); elSegment(0,true); elSegment(1,false); elSegment(2,false); elSegment(3,true); } delay(100); }
A friend of mine, who has been living in China, came back to Seattle to visit and showed me a cool little video camera which he picked up there for about $20. It was very tiny- it looked like a keychain, like one of those key fob remotes you use to unlock your car. I thought it would be interesting to attach one to a kite and see what kind of footage I could get.
The idea here was to make a coat which incorporated lights in some way. Since I’ve been playing around with the Arduino, I wanted to have the lights change in some kind of interesting way. At first, I was thinking of incorporating some kind of circuit to make it respond to music, but ultimately, I decided to use one of my compass modules and have the coat change color based on direction. Could come in handy while wandering around in a dust storm, right?
//All this does is read the heading from HMC6352 and spit it out via serial#include <Wire.h>int HMC6352SlaveAddress = 0×42;int HMC6352ReadAddress = 0×41; //”A” in hex, A command is:int headingValue;#define REDPIN 5#define GREENPIN 6#define BLUEPIN 3void setup(){// “The Wire library uses 7 bit addresses throughout.//If you have a datasheet or sample code that uses 8 bit address,//you’ll want to drop the low bit (i.e. shift the value one bit to the right),//yielding an address between 0 and 127.”HMC6352SlaveAddress = HMC6352SlaveAddress >> 1; // I know 0×42 is less than 127, but this is still requiredSerial.begin(9600);Wire.begin();pinMode(REDPIN, OUTPUT);pinMode(GREENPIN, OUTPUT);pinMode(BLUEPIN, OUTPUT);}void loop(){int r, g, b;//”Get Data. Compensate and Calculate New Heading”Wire.beginTransmission(HMC6352SlaveAddress);Wire.send(HMC6352ReadAddress); // The “Get Data” commandWire.endTransmission();//time delays required by HMC6352 upon receipt of the command//Get Data. Compensate and Calculate New Heading : 6msdelay(6);Wire.requestFrom(HMC6352SlaveAddress, 2); //get the two data bytes, MSB and LSB//”The heading output data will be the value in tenths of degrees//from zero to 3599 and provided in binary format over the two bytes.”byte MSB = Wire.receive();byte LSB = Wire.receive();float headingSum = (MSB << 8) + LSB; //(MSB / LSB sum)int headingInt = headingSum / 10;//blue to violetif (headingInt>=0 && headingInt<=60) {r=map(headingInt,0,60,0,255);;g=0;b=255;}//violet to redelse if (headingInt>60 && headingInt<=120) {r=255;g=0;b=map(headingInt,61,120,255,0);}//red to yellowelse if (headingInt>120 && headingInt<=180) {r=255;g=map(headingInt,121,180,0,255);b=0;}//yellow to greenelse if (headingInt>180 && headingInt<=240) {r=map(headingInt,181,240,255,0);g=255;b=0;}//green to tealelse if (headingInt>240 && headingInt<=300) {r=0;g=255;b=map(headingInt,241,300,0,255);}//teal to blueelse if (headingInt>300 && headingInt<=360) {r=0;g=map(headingInt,301,360,255,0);b=255;}analogWrite(GREENPIN, g);analogWrite(REDPIN, r);analogWrite(BLUEPIN, b);//comment out serial stuff for nowSerial.print(headingInt);Serial.print(” degrees”);Serial.print(” r: “);Serial.print(r);Serial.print(” g: “);Serial.print(g);Serial.print(” b: “);Serial.println(b);}
This was my second attempt at aerial kite photography. The first attempt was with a tiny video camera which I attached to the string of my butterfly-shaped kite. It got quite high off the ground, but the low frame rate of the camera, coupled with the unsteady motion of the kite itself, made for kind of a blurry picture.
This time I thought I could make some improvements by using a better, flip camera as well as a kite and camera mount made for the purpose. Unfortunately, kite and camera mount aside, it takes a ton of wind to lift a video camera with a kit. The kite never got more than about 20 feet off the ground, and I think it was even less stable than last time. This was my best flight (and the camera angle could have been better):
Most of the flights were like this:
I was using this camera mount specifically made to support cameras.
That concludes today’s exciting update. Don’t worry- I will be sure to post the riveting details of my next, sure-to-be-successful flight.
This is my first project using the Arduino. The goal was to come up with a simple way to spot my bike among many others in the dark.
I used the following parts for this project:
An arduino. I got started with it by following the tutorials on this site.
A wave shield. This comes as a kit which you solder together and then plug into the arduino. It reads sounds as wav files off an SD card.
A keychain remote with reciever.
A reed relay. I used this one, because it was cheap and I saw a reference to in an arduino foru
External speakers to play the sound. They plug right into the wave shield.
An el wire inverter. I broke the button and soldered wires in its place so that touching the wires together would light the el wire. I connected these wires to the reed relay so I could switch it from the arduino.
The arduino is programmed with the following sketch (which is based on this sketch). Basically, it listens for a signal from one of the four wires on the receiver, each of which correspond to one of the four buttons on the remote. If one of the buttons is pressed and the arduino gets the signal from the corresponding wire, it plays the sound file “one.wav”, “two.wav”, “three.wav” or “four.wav” off the SD card.
You can download the sketch here.