Step 3: Turn on Your Green LED

You will write your code in two basic sections: the “setup” section and the “loop” section. These sections are known as functions. We will learn more about what a function is later on!

The Setup function runs once when the arduino is turned on.
The Loop function runs continuously after the setup function runs once.

For you to turn on your LED, two things must happen.

First, you must tell the pin that you plugged in your LED to (in this case, PIN 3) to be in OUTPUT mode. This tells the pin that you’re going to send data out to it. You can set your pin to be in output mode using the pinMode function.

Second, you must tell the pin to be in HIGH mode. HIGH mode sends a high electrical signal through the pin. LOW mode sends a low electrical signal. You can set your pin on high mode by using the digitalWrite function.

// basic functions
// setup LED modes
// we're specifying that we're going to send information to this LED
pinMode(3, OUTPUT);

// High turns things on
digitalWrite(3, HIGH);