Here is something that you might find useful
const byte outPin = 3;
unsigned long currentTime;
unsigned long longPeriodStart;
unsigned long shortPeriodStart;
unsigned long longPeriod = 6000000; //6 seconds in microseconds
unsigned long shortPeriod = 1000; //1 millisecond in microseconds
boolean pulsing = true;
void setup()
{
Serial.begin(115200);
pinMode(outPin, OUTPUT);
currentTime = micros();
longPeriodStart = currentTime;
shortPeriodStart = currentTime;
}
void loop()
{
currentTime = micros();
if (currentTime - longPeriodStart >= longPeriod)
{
Serial.println("toggle");
pulsing = !pulsing;
longPeriodStart = currentTime;
shortPeriodStart = currentTime;
}
if (pulsing)
{
output();
}
}
void output()
{
if (currentTime - shortPeriodStart >= shortPeriod)
{
digitalWrite(outPin, !digitalRead(outPin));
shortPeriodStart = currentTime;
}
}
As written the code toggles between producing pulses for 6 seconds and not producing pulses for 6 seconds. To start producing pulses set the pulsing boolean to true for the required period, perhaps as a result of user input.