2 таймера
- Войдите на сайт для отправки комментариев
Вс, 02/10/2016 - 12:03
Здраствуите,
есть такая задача:
on/off LOw:
if LED_2 on
LED_2 off
reset timer air_id ??????????
pause ()sec
LED_1 on
else LED_2 off
LED_1 on
on/off HIGH:
LED_1 off
reset timer plasma_id ?????????????
LED_2 on
pause () sec
LED_2 off
сперва показалось что работает,но надо сбросить таймера при переходе состояния start_stop пина и тут запуталса.
#include <SimpleTimer.h> const int PLZ = 6; //start_stop const int LED_1 = 10; //plasma const int LED_2 = 11; //air int SF_1 = 0; int a = 0; int plasma_id; int air_id ; SimpleTimer timer; //***************AIR************************** void air() { digitalWrite(LED_1,LOW); digitalWrite(LED_2,HIGH); air_id = timer.setTimeout(4000, ISJ); } void ISJ(){ digitalWrite(LED_2,LOW); } // **************PLASMA*********************** void check(){ if(digitalRead(LED_2)==LOW && a==0) { digitalWrite(LED_1,HIGH); cut; } else{ plasma; } } void plasma(){ plasma_id = timer.setTimeout(2000,cut); } void stoptimer(){ digitalWrite(LED_2,LOW); } void cut(){ digitalWrite(LED_1,HIGH); if(a == 0) { digitalWrite(LED_1,LOW); } } void setup(){ pinMode(PLZ, INPUT_PULLUP); pinMode(LED_1, OUTPUT); pinMode(LED_2, OUTPUT); } void loop(){ timer.run(); SF_1 = digitalRead(PLZ); if(SF_1 == LOW) { delay(50); } if(SF_1 == LOW && a == 0) { check();//1 stoptimer();//2 plasma();//3 a = 1; } if(SF_1 == HIGH && a == 1) { delay(50); } if(SF_1 == HIGH && a == 1) { air(); a = 0; } }
htpicc@gmail.com
тз пришлите ydom@mail.ru Сделаем. Проверю код на макете, так что вы получите рабочий и проверенный код. Могу написать и на честном С, без ардуиновских костылей и тормозов.