In this lab we use the accelerometer in order to find the orientation of the device. If you have the orientation you can than see what axis’s of the devices are flat, and use the three axis’s x, y, and z as a leveler tool for finding how straight an object is.
This lab had many steps in the learning process. The first was finding out how to actually access the accelerometer in xcode, as you need to add the CoreMotion framcework. In order to use integrated sensors of the device as well as many external API’s in xcode you need to add them under “Frameworks and Libraries.” After adding the framework you can use object CMAcceleration and use the functions defined in the object. With this data pulled from the devices accelerometer we were able to find the orientation of the device. It does this by measuring the forces pulling on the device, for our purposes this is only gravity.
The next problem was just making the app look good oriented portrait and landscape, as adding constraints to the storyboard elements took a little bit to get used to. After this was done though it made a lot more sense.
This lab only accomplishes one Blugold, integrating a built-in sensor. Although it is quite simple, I think this app is very functional, as a person may not want to buy a spirit level or have one on hand. The apps layout is quite simple, the three orientations are listed, and a number between 0 and 1 is given. When the axis is relatively level (between .05 of 0 or 1), the label appears telling the user it is level.