Skip to content

Arduino Nano Setup

Sean Ye edited this page May 28, 2017 · 2 revisions

The Arduino Nano is a small microcontroller which will act as the brain of your robot. In order to set up your board you will need to install one piece of software.

  1. Arduino (follow the install links here) Choose the correct installer for your system and choose the Desktop version.

Open the arduino application and in the upper right click Tools->Board->Arduino Nano. This tells the arduino application which board we are using.

The arduino nano has a built-in light on it and our first program will be to turn the led light on and off at half second intervals.

The code is shown below and also in the code section here on github.

const int flash_pin = 13;

void setup() {
  pinMode(flash_pin, OUTPUT);
}

void loop() {
  digitalWrite(flash_pin, HIGH);
  delay(500);
  digitalWrite(flash_pin, LOW);
  delay(500);
}

Let's break this down line by line.

const int flash_pin = 13;

This line declares flash_pin as a variable, sort of like a variable named x in math. It provides us a way to easily access the number 13 later in the program. The reason flash_pin is 13 is because the teensyduino board has a light hard wired to this pin. We can create more lights later with some hardware.

void setup() {
  pinMode(flash_pin, OUTPUT);
}

This code is inside void setup() , where the code runs only once when the board gets power. pinMode(flash_pin,OUTPUT); tells the board that we want to treat pin 13 as an output instead of an input.

void loop() {
  digitalWrite(flash_pin, HIGH);
  delay(500);
  digitalWrite(flash_pin, LOW);
  delay(500);
}

Finally, void loop() runs over and over again. The digitalWrite tells the pin to switch on and then off with the delays in there to make sure there's time between the two states.

Once you've finished, plug in the nano and press the upload button on the top.

Clone this wiki locally