Getting Started
Download the Arduino IDE
Minimum Code
At a minimum, each piece of Arduino code (called a sketch) must have a setup()
function and a loop()
function.
void setup() {
// put your setup code here, to run once:
// the setup function runs once when you press reset or power the board
}
void loop() {
// put your main code here, to run repeatedly
// the loop function runs over and over again forever
}
Any line that started withs two slashes (//) is a comment and will not be read by the compiler
Simple LED Blinking
Getting an LED to blink is pretty much the simplest thing you can do with an Arduino to see physical output.
Components
LED
220 Ohm to 1k Ohm Resistor
Breadboard
2 x Male-male jumper wire
To build the circuit, connect one end of the resistor to Arduino pin 13.
Connect the long leg of the LED (the positive leg, called the anode) to the other end 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.
Circuit

Connect the circuit using a breadboard


Code
void setup() {
// LED_BUILTIN is a constant that is automatically set to the correct LED pin
// Set the LED_BUILTIN pin to be an output pin
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
digitalWrite(LED_BUILTIN, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(LED_BUILTIN, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Deploying
Open up the IDE and past in the above code


Plug in the Arduino to your computer via a usb cable. We need to tell the IDE to use the usb port. Select the plugged in Arduino from Tools > Port. You should only need to do this once.

Click upload in the IDE to copy the code over to the Arduino

Press the Reset button on the Arduino to run the code.

Last updated
Was this helpful?