Skip to content

noInterrupts

gicking edited this page Feb 6, 2018 · 2 revisions

back to Command Reference / Interrupt

Description

Disables interrupts (you can re-enable them with interrupts(). Interrupts allow certain important tasks to happen in the background and are enabled by default. Some functions will not work while interrupts are disabled, and incoming communication may be ignored. Interrupts can slightly disrupt the timing of code, however, and may be disabled for particularly critical sections of code.

Inclusion

  • defined in misc.h
  • auto-loaded in main_general.h
  • no #define required

Syntax

noInterrupts()

Parameters

  • input:

    • none
  • output:

    • none

Returns

  • Nothing

Example Code

The below code disables all interrupts, performs some time-critical code, and re-enable interrupts afterwards.

#include "main_general.h"   // board-independent main

void setup() {}

void loop()
{
  noInterrupts();
  // critical, time-sensitive code here
  interrupts();
  // other code here
}

Relevant Tutorial

  • tbd

See also

Clone this wiki locally