# Arduino IDE Quick Start

By completing this guide you will configure the Arduino IDE for developing on the Macchina M2 and run your first sketch on the M2. This will verify both your Arduino IDE setup and your M2 device.

The following steps are needed to get started programming on the Macchina M2 with the Arduino IDE:

1. Install the Arduino Desktop IDE
2. Install the Macchina M2 Board Configuration
3. Install drivers
4. Build and upload a sketch

## Arduino Desktop IDE

Follow the official installation instructions for your operating system then return here to continue with Macchina M2 specific setup.

* [Windows](https://www.arduino.cc/en/Guide/Windows)
* [macOS](https://www.arduino.cc/en/Guide/MacOSX)
* [Linux](https://www.arduino.cc/en/Guide/Linux)

## Macchina M2 Board Configuration

Now that you have the Arduino IDE Installed, you will add support for the for *Macchina M2*.

First, you will tell the IDE where to find the Macchina board configuration files. Go to ***File*** > ***Preferences***. Paste

```
https://macchina.cc/package_macchina_index.json 
```

into the ***Additional Board Manager URLs:*** box and press ***OK***. This tells the Arduino IDE where to look to find the board configuration files for Macchina boards.

Next, you will open the **Boards Manager** to download the needed board configurations. Find the board manager under ***Tools*** > ***Board: "\[...]"*** > ***Boards Manager..***.

In the board manager, install **Arduino SAM Boards (32-bit ARM Cortex-M3) by Arduino**. Then install **Macchina SAM Boards (Install Arduino SAM Boards first) by Macchina**.

Note: If for any reason you cannot use the Board Manager to install the board configuration files, you have the option to do a [manual install](https://github.com/macchina/arduino-boards-sam/blob/master/CONTRIBUTING.md#local-install-recommended) but will not benefit from the updates notification provided by the Board Manager when new versions are released.

{% hint style="warning" %}
Having an issue with the Boards Manager? See a common issue and its fix [HERE](broken://pages/-MOleEzJSrszpda8JsBi).
{% endhint %}

## Drivers

You may need to install a driver to enable your computer to communicate with the Macchina M2 before you can send sketches to it. The Macchina M2 is based on the Arduino Due and uses the same driver. Please visit the official Arduino Due documentation for [instructions on installing drivers](https://www.arduino.cc/en/Guide/ArduinoDue#toc4).

Be careful when plugging the micro-USB cable into your M2. The M2's design allows you to put it in a case or enclosure. The connector cable may stick out farther than you expect, because there needs to be clearance space for a case.

When you have finished installing drivers, leave your Macchina M2 plugged into the computer.

## Running your first sketch

Now that you have the Arduino IDE setup and your M2 connected, you can run your first sketch on the M2 by performing the followings steps in the Arduino IDE.

First, you will make **Macchina M2** the active board. ***Tools*** > ***Board: "\[...]"*** > ***Macchina M2***.

Next, select the port that your M2 is using. ***Tools*** > ***Port***.

Next, open the Blink sketch. ***File*** > ***Examples*** > ***01. Basics*** > ***Blink***.

Finally, in the opened window, upload the sketch to your M2 board. ***Sketch*** > ***Upload***.

It will take a few moments for the sketch to be written as firmware to your Macchina M2. You can watch the progress at the bottom of the IDE window. When the upload has completed, you should see a flashing LED on your Macchina M2.

Congratulations! You have now configured your computer for development on the M2 and run your first program. As a next step, you may choose to learn the names of the other LEDs on the Macchina M2 using the [pin mapping](/product-documentation/m2-docs/detailed-reference/pin-mapping.md). Then you can practice modifying the sketch to make other LEDs blink.

You may also wish to explore the other sketches under the ***Examples*** menu. Most libraries include examples which can be accessed by the ***Examples*** menu after the library is installed. The Macchina M2 Board Configuration you installed includes some libraries which will be listed under the ***Examples for Macchina M2*** section of the ***Examples*** menu.

## Resetting M2

If for some reason your M2 cannot be found by your computer, both in the Arduino IDE and the Device Manager, the M2 can be reset through the following process:

1. Connect the M2 to power.
2. Hold down the ERASE button.
3. While still holding the ERASE button down, press the RESET button.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.macchina.cc/product-documentation/m2-docs/arduino.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
