Thanks for the properly post code guidelines. I've fixed the original post to post the code correctly.
I will post a picture of the wiring later today.
As for the code, I intended to use it like this.
- Have the BMP280 sensor detect the altitude as the rocket is going up.
- When the sensor detects an altitude higher than my preset altitude, say 770 ft, a signal will send to control the servos.
- The servos will then turn 90 degrees to pull open the flaps for a few seconds to increase the frontal surface area of the rocket to increase drag to slow down the rocket. And after a few seconds, the servo should return back to 0 degree and close the flaps.
I tried to test this by using the code I post, and I wrote the following lines hoping that it would achieve the goal. My serial monitor showed the altitude reading to be somewhere around -14.5 meter. I stood on a chair, also lifted the sensor to above my head, and the altitude reading changed; however, the servos didn't move. I tried putting the sensor on the floor as well; the reading changed, but the servo also didn't move.