![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
2017能代宇宙イベント開放用プログラム(kobayashi)
Dependencies: mbed MS5607 MPU6050
main.cpp
- Committer:
- nene_kobayashi
- Date:
- 2017-08-05
- Revision:
- 2:3a7c38279b0b
- Parent:
- 1:fa1980f9b2d0
- Child:
- 3:507d05fb5cd8
File content as of revision 2:3a7c38279b0b:
#include "mbed.h" #include "MS5607I2C.h" #define RISE 0 #define DROP 1 MS5607I2C ms(p9,p10,false); DigitalOut myled(LED1); pwmout servo1(p23); int Phase=RISE; Ticker tic; float max=0; int count=0; void judge(){ switch(Phase){ case RISE: float alt = ms.getAltitude(); if(max <= alt){ max = alt; }else if(max > alt){ max = alt; count++; Phase=DROP1; } break; case DROP1: if(count=5){ servo1.pulsewidth(90); wait(1.0); } float alt = ms.getAltitude(); break; } int main(){ timer start(); tic.attach(&judge,0.1); while(1); return 0; }