clignotante.ino
The pin 13 LED blinks at 1 Hz, driven from the SysTick interrupt: loop() stays fully free. A typical pattern on Teensy boards, whose ARM Cortex-M core handles real hardware interrupts.
Hardware
A Teensy 4.1 (NXP i.MX RT1062, Cortex-M7 @ 600 MHz, 3.3 V logic, Ethernet and extra flash storage) powered over USB. No external component; the onboard user LED is enough.
Wiring
Nothing to wire for LED 13. Note: Teensy pins work at 3.3 V, not 5 V.
How it works
The systick_loop() function, a Teensyduino specific, is called every millisecond by the kernel; it checks millis() and toggles the pin. Shared variables are volatile to avoid compiler optimizations.
Running it
Teensyduino in the Arduino IDE, « Teensy 4.1 » board, Upload then the Teensy Loader button. 3.3 V pins; the 4.1 adds Ethernet, USB host and extra pins.
Variants
A simple version with delay(500) in loop(), or two LEDs at different rates by duplicating the logic with a period table.
clignotante.ino
// Clignotement LED sur la broche 13 (LED utilisateur Teensy).
const int LED = 13;
volatile bool etat = false;
volatile uint32_t dernierBlink = 0;
// systick_loop() est une specificite Teensy : appelee chaque ms
// par le noyau, la LED clignote meme si loop() est occupee ailleurs.
void systick_loop() {
uint32_t maintenant = millis();
if (maintenant - dernierBlink >= 1000) {
dernierBlink = maintenant;
etat = !etat;
digitalWrite(LED, etat);
}
}
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(9600);
while (!Serial && millis() < 2000); // attend l'ouverture du moniteur
Serial.println(F("Clignotement Teensy demarre"));
}
void loop() {
// Le coeur de travail est dans systick_loop() : loop() reste
// 100 % disponible pour d'autres traitements.
}