Code for Slider to Control Vertical Motor
Add this html somewhere between the body tags of your web app to add a slider:
Add this CSS in between the head tags of your web app to make your buttons, text, and slider look nice:
You should now see a slider on your web app, but it doesn't do anything. To get it to display values on your screen, first add the following within the deviceMotionHandler() function directly below where you set power and steering:
Directly below that, are the lines which insert values for power and steering into your html so that you can see what they are. Directly below those lines add:
Now, between the body tags of your web app, add the following element:
At this point, if you test your web app, you should see slider values appear and change as you move the slider up and down. However, if you look closely to the get request that is sent, you'll notice there is no value for lift. To send this information back to your controller, first create a variable for lift. Do this towards the top of your script (between your script tags) directly below the creation of your leftMotor and rightMotor variables.
Then, at the end of your deviceMotionHandler() function, add
Finally, within your start() and stop() functions, modify your calls to sendGetRequest so they include the vertical motor variable:
Directly before the stop() function, you'll also need to set the verticalMotor power to 0.
Then, set you vertical motor's initial power level to 0, just as you do with your left and right motors.
You should now be able to control your vertical motor.