1
Ардуино (Arduino) / Re: помощ arduino с бутон и реле
« -: Август 16, 2016, 09:31:34 am »#define SHORT_PULSE 220
#define SECOND 1000
int rele1 = 13 ;
int rele2 = 12 ;
int rele3 = 11 ;
int inpin = 8;
int ON = HIGH;
int OFF = LOW;
void setup ()
{
pinMode(inpin, INPUT);
pinMode(rele1, OUTPUT);
pinMode(rele2, OUTPUT);
pinMode(rele3, OUTPUT);
}
void loop()
{
bool pressed = digitalRead(inpin);
if (pressed)
{
digitalWrite(rele1, ON); //vkliu4va rele 1
delay(2 * SECOND); // 4aka 2 sekundi
digitalWrite( rele2, ON ); //vkliu4va rele 2
delay(SHORT_PULSE); // kratuk impuls
digitalWrite( rele2, OFF); // izkliu4va rele 2
delay(3 * SECOND ); // 4aka 3 sekundi
digitalWrite(rele2, ON ); //vkliu4va rele 2
digitalWrite(rele3, ON ); //vkliu4va rele 3
delay(SHORT_PULSE); // kratuk impuls
digitalWrite(rele2, OFF); // izkliu4va rele 2
digitalWrite(rele3, OFF); // izkliu4va rele 3
delay(120 * SECOND - 5 * SECOND - 2 * SHORT_PULSE); //dopulnitelno zabavqne do kraq na 2te minuti
digitalWrite(rele1, OFF); // izkliuchva rele1 2 minuti sled nachaloto na rabotata mu
}
}