/*
  文件名称：LED_Relay.ino
  功能：LED闪烁+继电器开启
*/

#define PIN_LED   5
#define PIN_RELAY1 16 
#define PIN_RELAY2 14
#define PIN_RELAY3 12
#define PIN_RELAY4 13

void setup() 
{
 pinMode(PIN_LED, OUTPUT);        //输出模式
 pinMode(PIN_RELAY1, OUTPUT);      //输出模式  
 pinMode(PIN_RELAY2, OUTPUT);      //输出模式
 pinMode(PIN_RELAY3, OUTPUT);      //输出模式
 pinMode(PIN_RELAY4, OUTPUT);      //输出模式
 digitalWrite(PIN_LED,HIGH);      //LED默认关闭
 digitalWrite(PIN_RELAY1,LOW );   //继电器1默认关闭
 digitalWrite(PIN_RELAY2,LOW );   //继电器2默认关闭
 digitalWrite(PIN_RELAY3,LOW );   //继电器3默认关闭
 digitalWrite(PIN_RELAY4,LOW );   //继电器4默认关闭
}

void loop() 
{
  digitalWrite(PIN_LED, LOW);    //打开LED  
  digitalWrite(PIN_RELAY1,HIGH );       
  delay(1000); //延时1S
  digitalWrite(PIN_LED, HIGH);   //关闭LED
  digitalWrite(PIN_RELAY2,HIGH );       
  delay(1000); //延时1S
  digitalWrite(PIN_LED, LOW);    //打开LED
  digitalWrite(PIN_RELAY3,HIGH );       
  delay(1000); //延时1S
  digitalWrite(PIN_LED, HIGH);   //关闭LED
  digitalWrite(PIN_RELAY4,HIGH );       
  delay(1000); //延时1S
  
  
  digitalWrite(PIN_LED, LOW);    //打开LED
  digitalWrite(PIN_RELAY1,LOW );
  digitalWrite(PIN_RELAY2,LOW );
  digitalWrite(PIN_RELAY3,LOW );
  digitalWrite(PIN_RELAY4,LOW );
  delay(1000); //延时1S
  digitalWrite(PIN_LED, HIGH);   //关闭LED
  delay(1000);
}
