How to Use an Arduino
Learning to use an Arduino is a great way to learn electronics and programming skills. Science Buddies has many cool science projects you can do with an Arduino. Before you can move on to more advanced projects, you need to learn the basics. This How to Use an Arduino series is the perfect place to get started. This simple tutorial will introduce you to how to setup an Arduino, how to program an Arduino, and how to connect electrical components to an Arduino. Follow along with our videos below and you will be building your own robots in no time.
Educators, our associated Introduction to Arduino lesson plan has additional classroom resources including student handouts.
Purchasing an Arduino
Just getting started with Arduino? The Science Buddies Electronics Kit for Arduino, available from our partner Home Science Tools, contains all the parts like buttons, LEDs, resistors, and switches that you will need to do the basic tutorials on this page.
Setting Up Your Arduino
This video shows you how to set up your Arduino for the first time, install the programming environment (called the Arduino Integrated Development Environment, or IDE), and run a built-in example program to blink an onboard LED. Make sure you follow the instructions on the Arduino software page to install the correct IDE for your operating system. Follow these getting started instructions if you want to use the web-based editor instead of installing it locally. If you have a Chromebook, see the Arduino Chrome App page.
Blink an External LED
This video shows you how to build a circuit on a breadboard, connect an external LED to your Arduino, and write your own Arduino program to make the LED blink on and off using the digitalWrite command.
Sometimes your circuit does not work as you expect. This can be frustrating for beginners because it is not always obvious what is wrong. Before you continue, you should develop some troubleshooting or "debugging" skills to help you fix broken circuits.
Tinkercad Circuits is a free circuit simulator that lets you prototype a circuit and run Arduino code in a web browser. It is a great way to start learning if you do not want to spend money on a physical Arduino yet, or if you want to test out code before trying it on a real Arduino. This video shows you how to create a basic circuit and run a simulation. Note that many of our tutorials use Tinkercad Circuits to demonstrate circuits or code, but you can always follow along with a physical Arduino.
Use a Button
In this video, you'll learn how to use a button as an input to your Arduino with the digitalRead command. You'll use the button to control an LED instead of automatically blinking the LED on and off. This starts your exploration into Arduino features that you can use in more advanced projects.
In this video you'll learn how to control an LED's brightness using the analogWrite command. Once you understand this command, you can also use it for more advanced Arduino programming tasks, like controlling the speed of a motor.
Use a Potentiometer
While a button only provides a digital input (on/off), a potentiometer provides an analog, or continuously variable input. In this video you'll learn how to use the Arduino's analogRead command. Combined with the analogWrite command from the previous video, you can make your own "dimmer switch" to control the brightness of an LED.
PING Ultrasonic Distance Sensor
An ultrasonic distance sensor, also called a sonar sensor, emits bursts of ultrasonic sound and measures how long they take to bounce back to the sensor. This is the same principle used by animals like bats for echolocation. This video will show you how to use the PING sensor from Parallax, a popular ultrasonic sensor for Arduino projects.
HC-SR04 Ultrasonic Distance Sensor
The HC-SR04 is another popular ultrasonic sensor for Arduino projects. It is much cheaper than the PING, but its performance is not always as reliable. This video shows you how to modify PING sensor code to work with the HC-SR04.
Positional Servo Motor
You can use your Arduino to control the rotational angle of a positional servo motor. Unlike continuous rotation servo motors, positional servo motors have a limited rotation range, usually about 180 degrees. They are useful for building things that do not need to go through a full rotation, such as the joint of a robotic arm.
Continuous Rotation Servo Motor
Continuous rotation servo motors look identical to positional servo motors, but their operation is slightly different. These servo motors can rotate continuously in either direction, but you cannot control their exact angle. Instead, you can use the Arduino to control their speed.
Learn to use a microphone with your Arduino's analog input to make projects that react to sound.
Did you know that you can connect a joystick, just like the type used in video game controllers, to your Arduino and use it to control things? A two-axis analog joystick like the one in this video just contains two potentiometers, one for each axis. So if you have already watched our potentiometer video above, then you are already well on your way to using a joystick!
Soil Moisture Sensor
Resistive soil moisture sensors work by measuring the resistance between two probes inserted into the soil. The sensor converts this resistance to a voltage that you can read with one of the Arduino's analog inputs. These sensors are useful for automatic plant-watering projects, but they require calibration since the definition of "wet" and "dry" soil will vary depending on the application. This video walks you through setting up and calibrating the sensor.
Learn how to control a pump with an Arduino for all your DIY plant-watering and hydroponics projects! While you can power a very small pump directly from your Arduino, larger pumps will require external power, so the video also covers how to do this.
Brushed DC motors are the bread and butter of many Arduino projects with moving parts. Since even very small motors typically require more current than the Arduino can provide, this video shows how to use a circuit part called a transistor to control power from an external source (like a battery pack). You will also learn how to control the motor's speed.
How do you control a motor's speed and change its direction? With an integrated circuit called an H-bridge! This video shows you how to use the L293D, a popular H-bridge that allows bidirectional control of two motors. Perfect for wheeled robots and autonomous cars.
Add remote control to your projects with an RC transmitter and receiver! This video shows how to connect an RC receiver to your Arduino and read its output signals using the pulseIn command. This lets you take a hobby RC remote and use it to control your Arduino project! Use it to cut the cord and add wireless control to a project like our Arduino ROV.
Powering Your Arduino Project
There are many different ways to power an Arduino project. You will probably start off using a USB cable plugged into your computer, but you can also power an Arduino through the barrel jack or the Vin pin. What type of power source you use will depend on the power requirements for your project and whether it is stationary or mobile. This video provides an overview of some different options.
Buzzers let you add sound as an output to your Arduino projects. There are two different common types of buzzers: active and passive. Active buzzers require a DC power supply and produce a constant tone, while passive buzzers can produce variable-frequency tones using the Arduino tone() command. This video shows you how to use both types.
This video shows how to use a 1602 liquid crystal display (LCD) with your Arduino. "1602" indicates that this screen has 16 columns and 2 rows of characters, but other sizes are available. This screen uses parallel communication with the Arduino, meaning it requires more wires than an I2C interface, but they are a common and easy way to add text display to your Arduino projects!
Flex sensors are a type of variable resistor. Their resistance changes when they bend. You can use them to do things like measure the amount of flex in the finger of a glove. This video shows you how to use one to control LEDs with an Arduino analog input.
This type of force sensor is called a force sensitive resistor (FSR). Their resistance changes when pressure is applied to the pad. They are not very accurate, so they are not well-suited for precise applications like building a scale where you need an exact measurement of weight. However, they work great for approximate force measurements, or when you want something that gives a continuous analog response when pressure is applied, instead a digital on/off response like a button.
This type of slide switch, also called a single-pole double-throw (SPDT) switch, is used commonly with Arduino projects. Unlike a pushbutton, which is spring-loaded and will pop back to its original position when you release it, this switch will hold its position when you let go. You can use them as a type of digital input or as a standalone power switch.
Vibration motors, also called eccentric rotating mass (ERM) motors, are used in devices like cell phones and video game controllers to make them vibrate. They are typically much smaller than larger motors that you would use to drive motors or propellers, as shown earlier in our tutorial series. They are a great way to add vibration (for example, for haptic feedback) to your Arduino projects. They are available in different sizes and shapes, including cylindrical motors with an external rotating mass, and "coin" or "pancake" motors with no external moving parts.
Passive infrared (PIR) sensors are used in home security systems and motion-activated lights. They are activated by moving infrared light sources such as body heat. They are a great way to add motion detection to your projects if you want to detect people or animals, but they won't work on room-temperature inanimate objects. Check out this video to learn how to use one.
Photoresistors, also called photocells or light dependent resistors (LDRs), are a simple way to add light sensing to your Arduino projects. They aren't very accurate, so are not great for precise measurements of light levels, but they work for measuring coarse changes or when an object is covered by something. Watch this video to learn how to use them in your projects.
RGB LEDs contain red, green, and blue LEDs in a single package, allowing you to independently control their brightness and mix colors. Learn how to use them and add some awesome lighting effects to your next Arduino project! Check out the earlier videos in this series on LED fading and using potentiometers for some helpful background information for this video.
Cool Arduino Projects
There are many interesting Arduino science projects you can do! This video shows a few. You can see a larger list of options in our library of science projects.