Loading...
Searching...
No Matches
Sketch structure

setup(), loop() and the start-up order. More...

Functions

void setup (void)
 Written by the sketch: runs once after reset, on core 0.
void loop (void)
 Written by the sketch: runs over and over after setup(), on core 0.
void yield (void)
 Called while delay() or USB Serial is waiting.
void init (void)
 Core start-up, before setup(): sets the CPU speed (Tools > CPU Speed), the ADC, USB and the inter-core FIFO.
void initVariant (void)
 Board start-up, after init(): the on-board ADC and the USB-PD controller.

Detailed Description

setup(), loop() and the start-up order.

Start-up: init() (core), then initVariant() (board), then setup() once, then loop() forever. A sketch that also defines setup1() and loop1() runs them on the second core at the same time (Multicore).

Function Documentation

◆ setup()

void setup ( void )

Written by the sketch: runs once after reset, on core 0.

USB Serial is already running; add while (!Serial) {} to wait for the Serial Monitor before printing. With FreeRTOS, setup() and loop() run in a task (FreeRTOS).

Examples
AnalogAveraging.ino, AnalogBurst.ino, AnalogBurstBackground.ino, AnalogDifferential.ino, AnalogMillivolts.ino, AnalogReadMultiple.ino, CmsisRtos2Threads.ino, FreeRtosQueue.ino, FreeRtosTasks.ino, I2CScanner.ino, MulticoreBasics.ino, MulticoreFifo.ino, PeripheralReceiver.ino, SpiLoopback.ino, and UsbPdPower.ino.

◆ yield()

void yield ( void )

Called while delay() or USB Serial is waiting.

Does nothing unless the sketch defines its own; with FreeRTOS, it lets other tasks of the same priority run.