示例#1
0
文件: syc-002.cpp 项目: dome2048/syc
int SYCcommand(String command)
{
	if (command == "1") {   
		digitalWrite(V1, HIGH);
		digitalWrite(ledG, LOW);
		watering = true;
		countdown = startCountdown * 40000;
		beep3();
		beep3();
		return 1;
	} else if (command == "0") {
		digitalWrite(V1, LOW);
		digitalWrite(ledG, HIGH);
		watering = false;
		beep4();
		beep4();
		return 0;
	}
	else {
		beep2();
	}
  
}
示例#2
0
int main(void) {
    init();

    while(1) {
        switch (mode) {
            case 0: // watch mode
                LED_R = 0;
                LED_G = 0;
                BZ = 0;
                if ( LIM_SW == 1 && cnt_lim_sw >= LIM_SW_WAIT ) {
                    clear_cnt();
                    mode = 1;
                }
                break;

            case 1: // monitor mode
                LED_R = 1;
                LED_G = 0;
                BZ = 0;
                if ( LIM_SW == 0 && cnt_lim_sw >= LIM_SW_WAIT ) {
                    beep1();
                    clear_cnt();
                    mode = 0;
                } else  if ( cnt >= MONITOR_TIME ) {
                    clear_cnt();
                    mode = 2;
                } else if ( P_SW_G == 0 && cnt_psw_g >= P_SW_WAIT ) {
                    beep2();
                    clear_cnt();
                    mode = 3;
                }
                break;

            case 2: // alart mode
                if ( LIM_SW == 0 && cnt_lim_sw >= LIM_SW_WAIT ) {
                    beep1();
                    clear_cnt();
                    mode = 0;
                } else if ( ( P_SW_R == 0 || P_SW_G == 0 )&& cnt_psw_r >= P_SW_WAIT ) {
                    beep2();
                    clear_cnt();
                    mode = 3;
                }
                else {
                    alart();
                }
                break;

            case 3: // pause mode
                LED_R = 1;
                LED_G = 1;
                BZ = 0;
                if ( LIM_SW == 0 && cnt_lim_sw >= LIM_SW_WAIT ) {
                    beep1();
                    clear_cnt();
                    mode = 0;
                }

                if ( cnt >= PAUSE_TIME ) {
                    clear_cnt();
                    mode = 2;
                }
                break;
        }
    }

    return (EXIT_SUCCESS);
}