Lets make an LED blink!
For this project all we need is an UNO board, a usb cable, and the IDE. This mini project will get you oriented to the UNO, the IDE, and the code that makes it do stuff.
IDE = Integrated Development Environment = an application that allows you to edit/write code, compile it, and send it to Arduino devices.
First Arduino program
Open Arduino Software IDE.
Blink. This will open a new window with the Blink program. These built in examples are a great way to learn. You don’t need to write code from scratch: borrow. That is the power of code!
Sketches are programs written using the Arduino IDE. Each is saved in its own folder and has the extension .ino.
- Take a first look at the code:
//means the line is a comment. The computer will ignore it - humans only! Multiple line comments are enclosed between
*/. For example,
/* this is a comment */
- Each Arduino program is made of two functions,
loop(). Code in the
setup()runs one time when the board starts up. Next, code in the
loop()runs and then repeats until you pull out the plug!
Plug your usb cable into your UNO and computer.
On IDE, click
Arduino/Genuino UNOto set up the correct board.
Portand select the port where your UNO appears.
Uploadarrow icon. The IDE will verify, compile, and upload your program to the UNO. Any errors will appear in the console window below the text editor.
- Take a closer look at
pinMode()is a set up function that tells our board to use a specific pin as an output or input.
LED_BUILTINis a special variable that refers to a LED built in to a board.
digitalWrite()is like a switch:
delay()is a timer that make the program wait. The delay is given in milliseconds.
- Mod this code! Change the delay times or add more on/off’s, then click the upload arrow to get it running on your board. Congrats: you are a programmer!
Next step: make Uno Buzz!