MThardPWM: Example 1
Event management for Uno, Nano, Mega
Blinking of an LED
This program will blink LED_BUILTIN
We will use the hard PWM. On a mega, LED_BUILTIN corresponds to a pin accepting this HARD PWM, there is nothing more to do. On a Uno/Nano, the LED_BUILTIN pin does not accept it, you can use output 9 to make the PWM and put a wire between pin 9 and pin 13. If you say nothing, pin 13 will be in INPUT which is what you need.

or:

or:

Complete program recommended
This program is completely under interruption, and releases loop which can be used to do something else.
// This program makes the LED_BUILTIN blink. A wire is needed between the // pin 9 and 13 for a Uno/Nano #include <MTobjects.h> // V1.0.6 See http://arduino.dansetrad.fr/en/MTobjects // On Uno/Nano the usable pins are: 9, 10. wHere we have to put a wire between pin 9 and pin 13 MThardPWM Blink(9, inpulses_width 500000 micro_seconds, periods_width 1000000 micro_seconds); // On Mega the usable pins are: 2, 3, 5, 6, 7, 8, 11, 12, 13, 44, 45, 46 //MThardPWM Blink(LED_BUILTIN, inpulses_width 500000 micro_seconds, periods_width 1000000 micro_seconds); void setup(){} void loop(){}