hige dura
/
hackathon1
ポイカメラ
main.cpp@0:1f81cf4cac84, 2016-01-31 (annotated)
- Committer:
- higedura
- Date:
- Sun Jan 31 00:54:11 2016 +0000
- Revision:
- 0:1f81cf4cac84
???????????????
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
higedura | 0:1f81cf4cac84 | 1 | #include "mbed.h" |
higedura | 0:1f81cf4cac84 | 2 | |
higedura | 0:1f81cf4cac84 | 3 | DigitalOut led_b(LED1); |
higedura | 0:1f81cf4cac84 | 4 | DigitalOut led_g(LED2); |
higedura | 0:1f81cf4cac84 | 5 | DigitalOut led_r(LED3); |
higedura | 0:1f81cf4cac84 | 6 | DigitalIn button_cam(P0_12); |
higedura | 0:1f81cf4cac84 | 7 | DigitalIn button_mov(P0_13); |
higedura | 0:1f81cf4cac84 | 8 | DigitalOut fet_ready(P0_0); |
higedura | 0:1f81cf4cac84 | 9 | DigitalOut fet_cam(P0_23); |
higedura | 0:1f81cf4cac84 | 10 | DigitalOut fet_mov(P0_14); |
higedura | 0:1f81cf4cac84 | 11 | |
higedura | 0:1f81cf4cac84 | 12 | |
higedura | 0:1f81cf4cac84 | 13 | int main(){ |
higedura | 0:1f81cf4cac84 | 14 | |
higedura | 0:1f81cf4cac84 | 15 | led_r = 0; |
higedura | 0:1f81cf4cac84 | 16 | led_g = 0; |
higedura | 0:1f81cf4cac84 | 17 | led_b = 1; |
higedura | 0:1f81cf4cac84 | 18 | |
higedura | 0:1f81cf4cac84 | 19 | int flag_ready = 0; |
higedura | 0:1f81cf4cac84 | 20 | int flag_mov = 0; |
higedura | 0:1f81cf4cac84 | 21 | |
higedura | 0:1f81cf4cac84 | 22 | while(1){ |
higedura | 0:1f81cf4cac84 | 23 | |
higedura | 0:1f81cf4cac84 | 24 | if(button_cam == 1 || button_mov == 1){ |
higedura | 0:1f81cf4cac84 | 25 | led_r = 0; |
higedura | 0:1f81cf4cac84 | 26 | led_g = 1; |
higedura | 0:1f81cf4cac84 | 27 | led_b = 0; |
higedura | 0:1f81cf4cac84 | 28 | fet_ready = 1; |
higedura | 0:1f81cf4cac84 | 29 | wait(0.1); |
higedura | 0:1f81cf4cac84 | 30 | fet_ready = 0; |
higedura | 0:1f81cf4cac84 | 31 | flag_ready = 1; |
higedura | 0:1f81cf4cac84 | 32 | wait(1); |
higedura | 0:1f81cf4cac84 | 33 | } |
higedura | 0:1f81cf4cac84 | 34 | |
higedura | 0:1f81cf4cac84 | 35 | while(flag_ready == 1){ |
higedura | 0:1f81cf4cac84 | 36 | if(button_cam == 1){ |
higedura | 0:1f81cf4cac84 | 37 | led_r = 1; |
higedura | 0:1f81cf4cac84 | 38 | led_g = 0; |
higedura | 0:1f81cf4cac84 | 39 | led_b = 0; |
higedura | 0:1f81cf4cac84 | 40 | for(int i=0;i<10;i++){ |
higedura | 0:1f81cf4cac84 | 41 | fet_cam = 1; |
higedura | 0:1f81cf4cac84 | 42 | wait(0.1); |
higedura | 0:1f81cf4cac84 | 43 | fet_cam = 0; |
higedura | 0:1f81cf4cac84 | 44 | wait(0.1); |
higedura | 0:1f81cf4cac84 | 45 | } |
higedura | 0:1f81cf4cac84 | 46 | led_r = 0; |
higedura | 0:1f81cf4cac84 | 47 | led_g = 1; |
higedura | 0:1f81cf4cac84 | 48 | led_b = 0; |
higedura | 0:1f81cf4cac84 | 49 | wait(1); |
higedura | 0:1f81cf4cac84 | 50 | } |
higedura | 0:1f81cf4cac84 | 51 | if(button_mov == 1){ |
higedura | 0:1f81cf4cac84 | 52 | led_r = 1; |
higedura | 0:1f81cf4cac84 | 53 | led_g = 1; |
higedura | 0:1f81cf4cac84 | 54 | led_b = 1; |
higedura | 0:1f81cf4cac84 | 55 | fet_mov = 1; |
higedura | 0:1f81cf4cac84 | 56 | wait(0.1); |
higedura | 0:1f81cf4cac84 | 57 | fet_mov = 0; |
higedura | 0:1f81cf4cac84 | 58 | flag_mov = 1; |
higedura | 0:1f81cf4cac84 | 59 | wait(1); |
higedura | 0:1f81cf4cac84 | 60 | while(flag_mov == 1){ |
higedura | 0:1f81cf4cac84 | 61 | if(button_mov == 1){ |
higedura | 0:1f81cf4cac84 | 62 | fet_mov = 1; |
higedura | 0:1f81cf4cac84 | 63 | wait(0.1); |
higedura | 0:1f81cf4cac84 | 64 | fet_mov = 0; |
higedura | 0:1f81cf4cac84 | 65 | flag_mov = 0; |
higedura | 0:1f81cf4cac84 | 66 | } |
higedura | 0:1f81cf4cac84 | 67 | } |
higedura | 0:1f81cf4cac84 | 68 | led_r = 0; |
higedura | 0:1f81cf4cac84 | 69 | led_g = 1; |
higedura | 0:1f81cf4cac84 | 70 | led_b = 0; |
higedura | 0:1f81cf4cac84 | 71 | wait(1); |
higedura | 0:1f81cf4cac84 | 72 | } |
higedura | 0:1f81cf4cac84 | 73 | } |
higedura | 0:1f81cf4cac84 | 74 | |
higedura | 0:1f81cf4cac84 | 75 | } |
higedura | 0:1f81cf4cac84 | 76 | |
higedura | 0:1f81cf4cac84 | 77 | } |