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)