ArduinoM0 Blink example

The Blink example is a good start to use you new board.
The example is very simple. It uses a LED and it blinks it.

Hardware Required

  • Arduino Board
  • LED
  • Resistor (anything between 220 ohm to 1K ohm)


To build the circuit, connect one a resistor to Arduino PIN 13. Connect the long leg of the LED (the positive leg, called the anode) to the other pin of the resistor. Connect the short leg of the LED (the negative leg, called the cathode) to the Arduino GND, as shown in the diagram and the schematic below.

Most Arduino boards already have an LED attached to pin 13 on the board itself. If you run this example with no hardware attached, you should see that LED blink.


After you build the circuit plug your Arduino board into your computer, start the Arduino IDE, and enter the code below.


The pinMode function in the setup block, sets the pin 13 as output.

pinMode(13, OUTPUT);

In the loop block, the digitalWrite function turns on the LED
This supplies 5 volts to pin 13. That creates a voltage difference across the pins of the LED, and lights it up.

digitalWrite(13, HIGH);

The LED is turned off by the following function

digitalWrite(13, LOW);

That takes PIN 13 back to 0 volts, and turns the LED off.
The delay function, pauses the sketch before proceding with the next block of code.
In this case, the delay function is used to let the user see if the LED is turn on or off, because otherwise without delay operations will be too fast for the human eye to be seen.

Copy and paste this code (or load it from your IDE by going into "Examples - blink") and upload it to your board.

// setup() is the first function executed when you plug you board
// or when you reset it. This funcion runs once
void setup() {
// The pinMode sets digital pin 13 as an Output
pinMode(13, OUTPUT);

// After the setup() function, the loop runs over and over
// until you stop the board
void loop() {
digitalWrite(13, HIGH);   // turn the LED on setting the pin 13 to HIGH
delay(1000);// wait for a second
digitalWrite(13, LOW);    // turn the LED off setting the pin 13 to LOW
delay(1000);// wait for a second