MTclockDouble: Example 1
Event management for Uno, Nano, Mega

Flashs with a LED

We will use a double metronome, one in two events will turn it on, one in two events will turn it off. This is a classic example that can be used as a basis for tasks such as programming a fan, an engine ... A PWM (hard o soft) would also be a solution.

Complete program recommended

This program is completely under interruption, and releases loop which can be used to do something else.

// This program will flashs a LED

#include <MTobjects.h> // V1.0.6 See http://arduino.dansetrad.fr/en/MTobjects

void lightOn(void)
{
  digitalWrite(LED_BUILTIN, HIGH);
}

void lightOff(void)
{
  digitalWrite(LED_BUILTIN, LOW);
}

MTdoubleClock Metronome(500 milli_seconds, 100 milli_seconds, lightOn, lightOff);



void setup()
{
  pinMode(LED_BUILTIN, OUTPUT);
}

void loop(){}