Project 3

I think I might have to tweak this idea. It's probably too much for one person to do.

My project idea is to come up with a game that uses the gyroscope, accelerometer, light/camera and sound sensors that most mobile devices have.

I want to make a simpler and smaller version of a game called WarioWare that is a collection of minigames. For my project I will be creating a small collection of mini games, about 3, all using sensors in order to play

Most of the games in Warioware are random and dont make much sense but they are all games that are based on sensors of the game console. So i will emulate that sort of gameplay but on the phone

The first minigame would use the gyroscope to flip pancakes, the second will use the accelerometer and gyroscope to shake a can of soda, and the third will use the light sensor to read the brightness of the room and turn off the light. There could possibly be a fourth minigame that uses the mic.That minigame would require the user to soothe the baby to sleep by making some noise

The purpose of the app is to be silly and fun, the audience will be users who want to play a game

prototype.pdf
HERE IS A LINK TO THE GITHUB FOR MY PROJECT

Lab-12 questions


1.What kind of data will you collect for sensors?

I will be using about 3-4 different types of sensors for my project.
*TYPE_ACCELEROMETER will return 3 acceleration values in the x,y,z directions. the values are in meters/second^2. Acceleration is a vector with magnitude and direction. X is the right and left of the phone. Y is the top and bottom of the phone. Z is the face and back of the phone.
*TYPE_GYROSCOPE will return 3 angular speed values in the x,y,z directions. the values are in rad/s. Gyroscope measures the rotation of the phone around these axes. The axes are used the same as in the accelerometer the only difference is the additon of rotations on every axis. Rotating counter-clockwise is rotating in the positive direction, rotating clockwise is rotating in the negative direction.
*TYPE_LIGHT is measured in units of lux (lx is a SI derived unit) that measures the luminous flux per unit area, the illuminance of a area. This sensor is an enviromental sensor that measures the ambient light.


2.What is the range of possible values?

The range of possible values for the accelerometer varies depending on the device but some range to +/-2G (19.6133ms2), +/-4G(39.2266ms2), and +/-8G (78.4532ms2).
The range of possible values for the gyroscope depends on the device but some measure a range of 0 to 30 rad/s.
The range of possible values for the light sensor depends on the device but some have measured the range to be between 0 to over 16000 lx.


3.How will you test the sensor?

I will test each sensor by ... I dont know actually. I will use android studio in combination with my own personal android device to run and test the app as I progress. Andorid has a function called getSensorList() that checks for the presence of sensors. If the sensor returns anything greater than 0 then it will return true and means the sensor is present.

4.Push your project to github, How did you do it?

I usually push onto github directly through the website, but I think I figured out how to connect to my github and push my project through Android Studio. I just followed this tutorial:
Link to article

Project 3 Final


Note: I was testing my app with my physical device, so it does not test well through the emulator.

SO, for starters I could not finish the app for a number of reasons. I ran into a lot of roadblocks and errors. As of right now my app has all the sensors in place reading the data and stepping through to the next activity.
One of th emost difficult things for me to understand and implement was the graphics and texturing of the project. I tried looking up how to create shapes on android and found articles for using paint and canvas, but I didnt really have enough time to learn how to implement and use the library correctly. Because of that, I dont have any graphics for my game.
I do however have part of the game mechanics in place. Starting with the first game I implemented, the Soda shaking minigame.

Soda Shaking

For the soda shaking game, I only wanted to take in the data in the rotating in the z direction.
Moving back and forth really quickly.
For that, I used the accelerometer to detect when the phone has reached being on it's side at a full +/- 90degrees. I only read data from the x axis (z rotation) and I calculated the difference between the currentpoint and the last point.
That way, I would measure the speed from point to point and use that as a condition to register when the user has shaken the phone fast enough to consider a full shake.
Here is the motion I am registering:
image
Here we have the phone outputting when it has been turned on it's side: image image
Here is part of my code logic for registering the full shake.
There are few issues with the logic, Ask me about it if you want to know, but a few errors occur depending on wether the app is being run online or physically.
There is a sort of rubberband error with the code.
For the most part, if the user shakes their phone enough, then the activity finishes and steps through to the next one. image

Light ON/OFF


For the Light game, I wanted to use the front camera to measure the light in the room.
For this game I used the light sensor, that measure the light by lux. In order to win the game, the user must first turn on the light and then turn of the light.
Here is a gif of my code measuring the light and changing the background to indicate the "brightness" of the room. image
Here is my code and logic for measuring when the light has been turned on and off.
Something to note: I have the same rubberband like error as before.
This case of the error isnt my fault, since it is caused with the cameras delay and autofocusing.
Additonally, I wanted to measure the light from 0 lx (darkest) to a max of 1000 lx, since testing in the physical world made me realize that most indoor rooms are about that bright. Not everyone is standing in front of a bright light. image

Flipping


For the flipping game I wanted to only register when the phone has been flicked in the motion shown below.
For this, I once again used the accelerometer and only took in the data coming in from the z and y-axis (x-rotation). I wanted to the user to flick back and forth in the range of 009 and 090 (xyz).
Here is the motion I was trying to capture
image
Here are the values being outputed when the phone is on it's back and when it's upright. image image
Here is my code for flipping.
The logic doesnt make sense and doesnt work as well as I would like, it was hard trying to get the right values to register as a flip, because it would only do so if the phone is held perfectly straight.
It doesnt work well in person or on the emultor, but it's a start. image