uint16_t time=millis();
int StartTime;
int Lasttime;
int Na;
bool flag=true;
int b;
int c;
void setup() {
Serial.begin(9600);
pinMode(2, INPUT_PULLUP);
pinMode(3, INPUT_PULLUP);
pinMode(8, OUTPUT);
pinMode(7, OUTPUT);
}
void loop() {
switch(b){
case 3:digitalWrite(8, HIGH);
break;
case 4:digitalWrite(8, LOW);
b=0;
break;
}
switch(c){
case 1:Serial.println("dolgo nazal");
break;
//case 0:Serial.println("otrabotal");
//break;
}
int Button = digitalRead(2);
uint32_t tmr;
static bool pstate=false;
bool state = !digitalRead(3);
if(pstate != state){
pstate=state;
Delay(500);
if (pstate && millis() - tmr >= 500) {
tmr = millis(); // сброс таймера
Serial.println("нажата");
}else{Serial.println("отжата");}
}
static bool pressState=false;
bool con=!digitalRead(4);
if(pressState !=con){
pressState=con;
Delay(500);
}
if(!(Button==1)){
Delay(500);
flag=false;
if(flag==false){
b++;
}
Serial.println("Chenge_Codition "+ String(b));
}
else{
flag=true;
}
}
void Delay(int Del){
int CurTime=millis();
Del+=CurTime;
while(CurTime<Del){
CurTime=millis();
}
}