bool _gen1I = 0;
bool _gen1O = 0;
unsigned long _gen1P = 0UL;
void setup()
{
pinMode(2, OUTPUT);
digitalWrite(2, 0);
Serial.begin(115200);
Serial.println("Hello, ESP32!");
}
void loop()
{
//Плата:1
if (1)
{
if (! _gen1I)
{
_gen1I = 1;
_gen1O = 1;
_gen1P = millis();
}
}
else
{
_gen1I = 0 ;
_gen1O= 0;
}
if (_gen1I)
{
if (_isTimer (_gen1P , 300))
{
_gen1P = millis();
_gen1O = ! _gen1O;
}
}
digitalWrite(2, _gen1O);
}
bool _isTimer(unsigned long startTime, unsigned long period)
{
unsigned long currentTime;
currentTime = millis();
if (currentTime>= startTime)
{
return (currentTime>=(startTime + period));
}
else
{
return (currentTime >=(4294967295-startTime+period));
}
}