I am going to soon begin trying to recreate one of these: http://www.thewandcompany.com/ using an arduino. This is my first project with arduino, so I will be starting slow by first just creating a setup that can learn and reproduce IR signals. I feel like I can handle this part, but the accelerometer has been making me a little more nervous.
I want to have at least 5 basic motions, flip up (volume up), flip down (volume down), right flick (channel up), left flick (channel down), and flick up & down (power). Has anyone worked with detecting these motions? I do not have my arduino or components yet, but I am just thinking ahead of time.
I don’t know if I posted this in the wrong place, please let me know if I did. I have been thinking about this problem, and have a bit of an idea of what I want to do.
First step would be to detect the direction of a voluntary motion. To do this I was thinking of the following (in sudo code).
threshold = # (how much the force needs to change before it is considered voluntary)
vals = readSensor
init_x = vals[xforce]
init_y = vals[yforce]
init_z = valz[zforce]
vals = readSensor
x = vals[xforce]
y = vals[yforce]
z = valz[zforce]
diff_x = x-init_x
diff_y = y-init_y
diff_z = z-init_z
if(diff_x>threshold): #Moved right
if(dir_x<threshold*-1): #Moved left
if(dir_y>threshold): dir = #Moved up
if(dir_y<threshold*-1): #Moved down
if(dir_z>threshold): #Moved forward
if(dir_z<threshold*-1): #Moved back
That is my basic idea for determining that there was a voluntary motion in a certain direction. From there, I would give an amount of time to wait for the next motion (milliseconds probably). Record the sequence of motions, and look to see if that sequence matched a pre-defined sequence. If it does, then fire a specific IR code.
I have never worked with accelerometers before, so I am sure I am missing something here. I realized the fact that the accelerometer sensor will detect gravity, but this should account for that. I might code this up for my phone soon to test it out.
I am interested in hearing opinions if anyone has them.
I've never done it myself (though it sounds a fun project) but there is some pseudo-code here http://www.codeshogun.com/blog/2009/04/17/how-to-detect-shake-motion-in-android-part-i/ and actual code here http://www.clingmarks.com/?p=25 that might help you.
I tried something fairly similar to that code, but gravity is kind of messing me up. I have some rotation when I am doing the motions, and that means that gravity starts to act on different axis in the middle of a motion. Back to the drawing board.