kk
Dependencies: SDFileSystem mbed
Fork of cansat_kk by
Diff: main.cpp
- Revision:
- 0:649fc30be6ec
- Child:
- 1:fa44a6246bcc
diff -r 000000000000 -r 649fc30be6ec main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Feb 29 11:10:31 2016 +0000 @@ -0,0 +1,99 @@ +#include "mbed.h" +#include "SDFileSystem.h" + +Ticker timer; +SDFileSystem sd(p5, p6, p7, p8, "sd"); // the pinout on the mbed Cool Components workshop board +Serial gp(p28, p27); // tx, rx +Serial pc(USBTX, USBRX); // tx, rx +PwmOut moterl(p21);//左モーター +PwmOut moterr(p22);//右モーター +DigitalOut led1(LED1); +DigitalOut fet3(p23);//ニクロム線 +DigitalOut led2(LED2); +DigitalOut led3(LED3); +DigitalOut led4(LED4); +DigitalOut janpa1(p19);//パラシュートの開きを検知 +DigitalIn janpa2(p20);//パラシュートの開きを検知 +int gosa; + +char gpsc[100]; +int a,b,c,d; +int i=0; + +void gps() +{ + led1 = 1; + + printf("Hello World!\n"); + + mkdir("/sd/mydir", 0777); + FILE *fp = fopen("/sd/mydir/sdtest.txt", "a"); + if(fp == NULL) { + error("Could not open file for write\n"); + } + + led1 = 0; + led2 = 1; + while(i!=50) + { fputc(gp.getc(),fp); + i++; } + fputc(a,fp); + + fclose(fp); + + led1 = 0; +} + + +void start() +{ + janpa1=1; + while(janpa2 == 1) + { led4 = 0; + led3 = 1;}//2 + +} + + + +void nikuromu() +{ + led4=1; + fet3=1;//3 + wait(60);//焼き切り時間 + led4=0; + led3=0; + led2=1;//4 +} + +void moter() { + while(1) + { + float offset=0.0; + float offset2=0.0; + moterl.period(0.02); // 周期 + moterr.period(0.02); + moterl.pulsewidth(0.08); // servo position determined by a pulsewidth between 1-2ms + moterr.pulsewidth(0.08); //パルス幅 + + + } + led2=led3=led4=1; + wait(1.0); + led2=led3=led4=0; + wait(1.0); + led2=led3=led4=1; +} + +int main() +{ + gp.baud(9600); + timer.attach(&gps, 2.0);//割り込み + led4 = 1; + start(); + wait(60);//落下中 + nikuromu(); + moter(); + + return 0; +}