Monday, November 25, 2013

The code works!!!

Five minutes at TA hours, and the code for the lights responding to the tilt sensor works!!!  I am so unbelievably happy!  I can't get the video to upload, but I'm so proud of it.

11/25/13: Class and office hours

THE TILT SENSOR IS FINALLY WORKING!!  The new code prints out logical values for the x and y axes that change in a predictable and understandable manner.  Unlike the raw data, this is useable and finally makes sense to me.

I only need to worry about two axes now (x and y) and can disregard z, since the new code doesn't recognize any motion in the z direction.  My short-term goal is have one strand of LEDs respond to tilt in the x direction and light up a different color depending on if the motion is in the negative or positive direction.  I will then code for another strand of lights to respond for the y axis.  To do this, I am transferring my Neopixel code from the raw-tilt-sensor-and-Neopixel-strand-combined code.  I've successfully compiled the sketch for just the x-direction, but the LEDs aren't reacting.  However, I feel optimistic that this isn't a huge problem to solve.  I have to go to other appointments now but will return for an hour or so tonight to try to finish this up before I leave for break.

New orientation of tilt sensor and Arduino
The beginnings of new combined code

Sunday, November 24, 2013

TA hours 11/24/13

Two hours in the TA session today (30 minutes with Nikki, the rest with Shani), and the tilt sensor has stopped functioning.  I wrote code to combine the tilt sensor and the Neopixel lights, and everything compiled properly, but it doesn't actually work in real life because of the situations the axes find themselves in.  That is, x can be greater than y but still less than z, so the tilt sensor just doesn't know what to do with the data.

Shani and I tried to figure out the new code from Audrey, but neither of us really understands what's going on with it.  We uploaded it to the Arduino and opened the serial monitor, and it basically just spewed out an incoherent stream of letters, which means that something's not hooked up properly.  We went to the blog where the code came from and tried to reconfigure the tilt sensor, but it still doesn't work.

Next, Shani and I focused in on my code, and I decided that it would be best to comment out one of the axes (x) so that the tilt sensor could be more focused.  It actually does respond and changes colors but then freezes and stops reading the data.  I don't know what to do about this.  It has happened multiple times, and I have no solution right now.

Thursday, November 21, 2013

TA hours 11/21/13

I went to Nikki's TA hours tonight (9:00-10:15...she's a saint), and she's helping me write the code I need for the tilt sensor to read values the way I need it to.  We've had to modify (again) the idea, so this what I will be doing:

  • The tilt sensor will read values in a certain range from the x, y, and z axes
    • We figured out the range by holding the tilt sensor on my back (where it will be placed on the skirt) and rotating around the different axes; from this, we found several ranges of values we don't want the sensor to use because they're too sensitive
  • After storing these values, the code compares x to y and z and then y to x and z to determine which is greater and light up the LED strand in that way (there will be specific colors or patterns for each axis pattern)
  • If neither of these works (i.e. equal values), the code will light the LEDs according to the z way, which must be true if neither x nor y are
Here's the document with my notes:



Nikki helped me write most of this, and I'm working on how to incorporate the LEDs now.  I feel a lot better...it's coming along!

(for 11/20/13)


I'm finally starting to work out how the tilt sensor functions.  From the work during class (and from Audrey's advice), I'm going to work with the gyroscope instead of the accelerometer, since time is running short and the accelerometer seems to be really unreliable.  I was shaking it and moving it with different speeds along the different axes but the values changed without making a lot of sense.  Because this, my design needs to be modified a bit.  I was initially going to separate the lights and spread them out underneath the chiffon layer of the skirt, but now, to accommodate the altered code, I will just attach the light strips around the ribbon (belt) of the skirt.  I think this will still be an interesting project and viable in the marketplace.  Here are my notes from the class about going forward:


Should change to gyroscope instead of accelerometer
·         X = rotating around center
·         Y = leaning forward/backward
·         Z = tilting side to side

If rotating on x-axis, light strip red
If tilting on y-axis, light strip blue
If tilting on z-axis, light strip green
If not tilting on x-, y-, or z-axis, light rainbow cycle

The text in red is the code I intend to write.

I've figured out the axes for the tilt sensor (at least in one particular orientation).  The videos won't upload right now, but I have them on my phone.

Tuesday, November 19, 2013

11/19/13

I've been sitting in TA hours for a little while, looking at my code and wondering what the difference between the "ax" and "gx" values are.  This seems obvious now, but I'm so excited to have figured out (by myself!) that "a" corresponds to the acceleration values and "g" corresponds to the gyroscope values!  I started to Google the tilt sensor and that reminded me of the gyroscope function, which led me to the conclusion about the "a" and "g" letters.  I'm quite proud of myself...!

I've been working on my pseudocode and have come up with the following:

scaled_ax = map(ax, -17000, 17000, 0, 179)
scaled_ay = map(ay, -17000, 17000, 0, 179)
scaled_az = map(az, -17000, 17000, 0, 179)
scaled_gx = map(gx, -17000, 17000, 0, 179)
scaled_gy = map(gy, -17000, 17000, 0, 179)
scaled_gz = map(gz, -17000, 17000, 0, 179)
 
If acceleration in the x-direction is a high value, cycle the rainbow quickly
                If scaled_ax is ________, quick rainbow cycle
If acceleration in the x-direction is a low value, cycle the rainbow slowly
                If scaled_ax is ________, slow rainbow cycle

If acceleration in the y-direction is a high value, cycle the rainbow quickly
                If scaled_ay is ________, quick rainbow cycle
If acceleration in the y-direction is a low value, cycle the rainbow slowly
                If scaled_ay is ________, slow rainbow cycle

If acceleration in the z-direction is a high value, cycle the rainbow quickly
                If scaled_az is ________, quick rainbow cycle
If acceleration in the z-direction is a low value, NOTHING
                If scaled_az is ________, do nothing

If acceleration in the x-, y-, AND z-directions are zero, DO NOTHING
                If scaled_ax, scaled_ay, and scaled_az are 0, do nothing
 
I was working on the basis that "z" is the up/down axis, but I guess that would actually be "y."  Nikki suggested that ignore that axis to make things simpler, and I agree with her.  Maybe I will add it in later if the code comes together reasonably well.

I need to test the lights to find a comfortable value for the delay.

So, the tilt sensor theoretically puts out values between 0 and 179, but Nikki reminded me that it's like the microphone in that it might never reach the ends of the full range, so I need to find a comfortable max and min value to work with.  I loaded the code onto the Arduino to experiment at a standstill, walk, jog, run, but the serial monitor isn't functioning properly, and I know everything is connected properly.  I'll continue this during lab tomorrow, but it has to be done then.

Time spent: ~ 1 hour

Here is the evolutions of my code:
 
  (this is the delay I need to alter)

Monday, November 18, 2013

11/18/13 (class)

After dealing with dead LED strips yesterday, I've been given another strip to experiment with, and I'm going to be very, very careful.  It was missing a wire to the +5V port, so I've solved that with a new soldered wire.  It's really difficult to solder the LED strips, so I'm going to need to budget a significant amount of time for attaching them individually to the skirt fabric.

I'm making progress with the code.  I've succeeded (with lots of help from Audrey) in combining the tilt sensor simple LED code with the code for the Neopixel LED strip (standtest).  Now that these two have been combined, I need to actually work on my goal, which is for the LEDs to read data from the tilt sensor and, depending on the amount of acceleration/motion sensed, cycle the rainbow appropriately slowly or quickly (I'm not sure what the LEDs should do when no motion is sensed).  At the moment, I'm in the pseudo-code stage of figuring things out.

I'm trying to conceptualize the x, y, and z axes in terms of dance and the skirt.  X and y are the logical values to work with, provisionally ignoring z, since it would only really correspond to if the dancer jumped straight into the air.  Jumps are important in dance, but I don't really know how to incorporate that into the code; it seems like way too many variables, but I don't want the skirt to go dark if the dancer jumps into the air without moving along the x or y axes...so I guess I do need to incorporate z...?

Pictures to follow!

Sunday, November 17, 2013

I went to TA hours tonight to try to figure out why my LED strand wasn't working.  I tested the strand with an Arduino, Meaghan's SquareWear, and my SquareWear, and I think it's just dead.  I don't know what could have happened to make it stop working because it was working Friday afternoon: it just spluttered and lit up erratically, then stopped lighting up at all.  I did connect it while the Arduino was on, but I don't think that should have bothered it...right?

I found another, longer strand to test, but that didn't work either!  I tried that on my SquareWear and on Ione's, and nothing happened.  Then Ione's weather-proofed strand stopped working.  I'm thinking that there's something wrong with the strands?  I can't move on with my project until we figure this out.
[This is a late post, because it is actually about Friday's work]

Since the code for Neopixel isn't working on my laptop, I tried setting up the board with the lab computer, and I got the LED strip to work!  Next, when I hooked up the wires for the tilt sensor and was getting ready to try to combine the two pieces of code, the lights suddenly stopped working.  The computer gave me the error, "Programmer is not responding."  I closed and reopened Arduino several times and I switched the power source for the LEDs from 5V to 3.3V, but neither worked.  I'm going to TA hours tonight to try to fix this.  I'm a little worried, though, because my code was supposed to be done last Wednesday, and nothing's working the way it should.

Wednesday, November 13, 2013

11/13/13

Today was the shopping trip to Jo-Ann's, and I am so excited to have all my materials ready to go!  I have a little less than a yard of black fabric for the under-layer of the skirt (where I'll be mounting all the components...actually looks like it will be sturdy enough to allow me to solder the LEDs directly onto it) and also found some beading wire that has copper wire inside.  It's so much thinner than the rainbow cable I was planning on using and will be much more subtle.  In the lab, I stripped two ends of a sample section and connected them to an LED/coin battery to check conductivity, and it has a strong connection.  I will post a video later.

Now, I just need to fix my code...I'm still getting the strange Adafruit Neopixel error on my computer, so I'll try uploading on the lab computer tomorrow or Friday and that will hopefully solve the problem.

Tuesday, November 12, 2013

11/12/13

The first time I started working on this was Sunday night.  I ran into problems because the code "TiltSensorSimple" is designed to work with the Arduino, not the SquareWear.  I was really hoping to use SquareWear since it is so much smaller and lighter, but, since the skirt is just a prototype, I guess I'll switch to Arduino instead.



Today, (11/12/13) after meeting with Audrey, I went to TA hours with Shani and Nikki and am trying to hook up the tilt sensor.  I ran the scan to confirm the sensor was hooked up properly, and I was ecstatic when it matched the guidelines!



 

Then, I hooked up LEDs with another breadboard and took a video of the tilt working.  Stupid mistake 101: I was tilting the board with the LED and exclaiming how frustrated I was that nothing was happening...Nikki pointed out that I needed to be tilting the tilt sensor.  Oops.















And now I have another major error.  It took a while to compile the new files (neopixel and the updated SquareWear2) and figure out where the Arduino files were hiding (not in neopixel but in SquareWear2).  Now I'm getting an annoying error, though:

I'm doing all this on my PC, which doesn't run SquareWear, so I'm thinking that could be the reason why...?  Something else I need to figure out is how to activate the accelerometer.  I want to use that function of the tilt sensor, but I'm pretty sure the code is working the gyroscope.