ポイカメラ

Dependencies:   mbed

main.cpp

Committer:
higedura
Date:
2016-01-31
Revision:
0:1f81cf4cac84

File content as of revision 0:1f81cf4cac84:

#include "mbed.h"

DigitalOut led_b(LED1);
DigitalOut led_g(LED2);
DigitalOut led_r(LED3);
DigitalIn button_cam(P0_12);
DigitalIn button_mov(P0_13);
DigitalOut fet_ready(P0_0);
DigitalOut fet_cam(P0_23);
DigitalOut fet_mov(P0_14);


int main(){
    
    led_r = 0;
    led_g = 0;
    led_b = 1;
    
    int flag_ready = 0;
    int flag_mov = 0;
    
    while(1){
        
        if(button_cam == 1 || button_mov == 1){
            led_r = 0;
            led_g = 1;
            led_b = 0;
            fet_ready = 1;
            wait(0.1);
            fet_ready = 0;
            flag_ready = 1;
            wait(1);
        }
        
        while(flag_ready == 1){
            if(button_cam == 1){
                led_r = 1;
                led_g = 0;
                led_b = 0;
                for(int i=0;i<10;i++){
                    fet_cam = 1;
                    wait(0.1);
                    fet_cam = 0;
                    wait(0.1);
                }
                led_r = 0;
                led_g = 1;
                led_b = 0;
                wait(1);
            }
            if(button_mov == 1){
                led_r = 1;
                led_g = 1;
                led_b = 1;
                fet_mov = 1;
                wait(0.1);
                fet_mov = 0;
                flag_mov = 1;
                wait(1);
                while(flag_mov == 1){
                    if(button_mov == 1){
                        fet_mov = 1;
                        wait(0.1);
                        fet_mov = 0;
                        flag_mov = 0;
                    }
                }
                led_r = 0;
                led_g = 1;
                led_b = 0;
                wait(1);
            }
        }
        
    }
    
}