Servo
To break it down, first we added Servo library Servo myservoName. The library created a new class or type of object that we can declare and use. This gave us access to all of the functions associated with the library on a particular pin. When we started using a Servo we added the following variable declaration.
Then we told servo which pins to use. We did this by adding the line of code servo.attach (pin number).
Finally, the servo spinning angle was determined after we passed the variable value int servoTarget = angle.toInt().
Although the second part of the code was a simple servo control code with a function to fetch data from the cloud, we faced a great difficulty trying to subscribe the first Photon and get the data from the particle cloud because we could not concatenate a string into an integer. Fortunately, we solved this problem by placing a temporary variable to catch the "pointer" to prevent system resetting the reference to the next value.
Another challenge we had occured due to our own mistake. We accidentally put the rotating wheel in the wrong order so the wheel spins from "healthy" person to "sleepy" person. We glued the rotating wheel so there was no way to change the physical component. Instead, we changed the code. The angle to spin was changed from "step" to "180 - step" so that the wheel could rotate from 180 degrees back to 0 degrees.
One more challenge was that the servo motor vibrates from time to time if the angle was too extreme. Our solution was to user constrain method to limit the angle from 5 degrees to 179 degrees, which was the range where we did not observe any issue.