Home STEM Arduino Basics

Arduino Basics

by Joy Liang

 Arduino Basics

Arduino is essentially LEGOs for tech lovers. The Arduino company creates boards which have small, built-in computers that allow control of motors, sensors, LEDs, etc. You can tell it what to do by writing code and uploading it to the board. Arduino creates many types of boards and shields (add-ons), but the most basic and most commonly used is called the Arduino Uno.

 

As complicated as it seems, Arduino isn’t hard to learn. 

 

Part 1: Parts of an Arduino Uno

 

As a beginner, there are only a few components of an Arduino that will be used.

  • USB Port: exactly what it sounds like. All Arduinos come with their respective USB port. Plug it into a computer to give it power and to upload code.

  • Reset Button: restarts a program.

  • V: there are 2 power pins. One outputs 3.3 volts while the other outputs 5 volts. Think of it as the positive side of a battery.

  • Ground: essentially the negative side of a battery.

  • Digital I/O: pins that allow you to connect motors, sensors, etc.

Part 2: Software

 

Most of the work you do with Arduino is code. Arduino has its own IDE and its own programming language. 

 

Part 3: A Basic Project

 

The Arduino IDE comes with many built-in projects with pre-written code; one of which is called “Blink”. The program turns an LED on for one second, then off for another second, repeatedly, as you would expect. The code is accessible in the Arduino IDE through File -> Examples -> 01. Basics -> Blink

 

 

Plug the Arduino into your computer with the USB cable. To successfully configure it, select Tools -> Board and make sure you have the correct board selected.

 

 

Select Tools -> Port -> COM3.

 

 

Now that the board is configured, I can start working on the code. The Arduino IDE gives me this program:

 

In almost every Arduino program, there will be two main functions: the setup function and the loop function. They work exactly like how they are named. The setup function runs once and the loop function runs over and over until it is terminated. There are three other methods in this program:

 

  • pinMode(pin, mode): initializes a pin to be either an input or output. In this case, it initializes pin LED_BUILTIN to be an output. Note that LED_BUILTIN is a constant defined in the Arduino language to be the pin the built-in LED on the Arduino board is connected to (in most cases, pin 13).

  • digitalWrite(pin, value): gives a pin either the value HIGH or LOW. The pin will receive 5V for HIGH and 0V for LOW.

  • delay(milliseconds): delays for a set amount of time.

 

A very helpful resource is the Arduino Reference, which gives information about commonly used methods. 

 

To upload code, click the upload button.

The program works as described- the built-in LED blinks.

 

To make this project slightly more complex, I will be building a simple circuit with a seperate LED and control it using the Arduino. Here is the circuit schematic:

As you can see, it is a simple circuit with the power source as the Arduino.

 

When building circuits, make sure you use a resistor! I have had my fair share of fried parts and LEDs.

 

After that, I made some modifications to the code. 

I defined the pin I connected the LED to (pin 7). The keyword “const” makes the variable read-only, meaning that it cannot be altered. In the functions pinMode() and digitalWrite(), I changed the parameters to myPin as well. After verifying and uploading the code, it works perfectly. 

 

Part 4: Next Steps

 

If this guide interests you and you want to learn more, check out their website at https://www.arduino.cc. One of my favorite resources is the Arduino Project Hub  which is a place for people to share their own projects and how they made them. 

 

If you are looking for a starter kit, I would recommend the ELEGOO UNO Starter Kit which I purchased a while ago. It comes with an Arduino Uno, jumper wires, LEDs, resistors, motors, and more. 

 

There is really an endless supply of things to do with these boards, whether it be as simple as a blinking LED or as complex as smart robots. Exploring the world of Arduino and electrical engineering has enabled me to be creative and make incredible projects with just the help of a tiny computer.

related articles

Leave a Comment