Image

Interface and Application Programming

Week 12

For the 12th week, we had to make a application. For this, I made an application that tells you when the dress in my final project would lift and when it wouldn't. I really don't understand python that much, so I chose to work off of the python script on the class website. However, it then prints "lift dress" or "lower dress" depending on if the accelerometer is moving (as if in a run) or if it isn't.

I wanted to mimic the structure of my C code for the accelerometer, so I had to find the change in the different coordinates to determine whether or not the person was running or walking. So, I needed to create a new variable for the old x and y values. If the change in coordinates is large enough then the code should output "lift dress". If not, then it should print "lower dress". In this case, I only wanted to use the x and y coordinates, since those are the ones changing the most while walking and running. To achieve this, I needed to create an absolute value function. Working off of the idle function and what I had googled, I was able to create the function without too much difficulty.

Although I thought my code was correct, the python script would freeze almost immediatly from starting the code. From the error in the terminal window, I found out that the reason it wasn't working is because I had created my variables at the very beginning of the code, but not defined them in the idle function. Once I did this, my code worked immediatly. The two pictures below show the lift and lower dress functionality. For the code, I left the bars and coordinates of the class code, since I thought they would be interesting to know if you needed more precision in the future.

Image placeholder
Image placeholder