Lab 0 β€” Introduction to Arduino

Lab 0 β€” Introduction to Arduino

🚫
Note, like reading 1, this lab is designed to be sort of a “crash course” and focuses more on linking to external resources and tutorials that you might find helpful in getting familiar with Arduino. We’ve structured it in an order that we think helps with learning, and we are always here to offer support so please reach out if you need help!

Hello and welcome to class and to Lab 0! This lab is optional to be completed on your own time but we ask you to skim it to make sure you’re comfortable with everything presented in this tutorial! We won’t necessarily assumer you’re perfectly familiar with everything in here, but details in Lab 0 will not be the focus of teaching for this class. It’s designed to bring you up to speed. But as always, we’re here to help so let us know anytime you need it!

The Classic Arduino Blink Tutorial

Blink is a basic tutorial with Arduino that lets you connect an LED to the board and make it flash at a specified frequency. Note that you can do this with an external LED, but all arduinos have an in-built LED as well. We haven’t given you external LEDs or resistors, so try to make this tutorial work with the built in LED. Note the tutorials in the previous section can help you in getting the Arduino connected to the programming environment.

The Blink tutorial is great because it gets you started with Arduino, familiar with the board and the programming environment, and it’s a great way to check that your Arduino works with a visual indication. Sometimes in embedded systems, it’s difficult because we can’t “see” the code running on the microcontroller.

Hello World but with Arduino

Hello World is a classic tutorial for all programming languages. Here we’re going to get the Arduino to print “Hello World” to what’s called the serial terminal.

Information on Serial Communications

Serial Communications is a class of communications protocols that send bits of data over a digital interface one after another (hence serial). Arduino uses UART which is Universal Asynchronous Recieve and Transmit, and this is how the computer communicates with your Arduino when its plugged in over USB.

Controlling a Servo with Arduino

A servo motor is a small motor with an internal position controller. The arduino can send signals to control the position of the motor. For example, if we wanted to open and close a small door in an automatic food dispenser for a cat, we could use a servo.

Basic Logic Tutorials

Now that we’ve moved a servo and controlled an LED, we can think about more complex logic systems including using buttons to activate actions. The most basic way to do this is an if-then statement.

Functions in Arduino

Functions are a basic programming technique used when we want to clean up a code file or when a code snippet will be repeatedly used often. It’s also often used when we want to pass data to a set of code for processing. You can read more about functions and learn to use them in the below tutorial.

Note, the last part of the tutorial reads from an analog sensor. We haven’t taught you to do that yet, so don’t worry if it doesn’t make sense!

Challenge

Here’s a challenge to try on your own! Did you know you can give inputs to the Arduino from the serial monitor? Check out this tutorial video on YouTube β†—. See if you can write a calculator that takes two numbers as an input, multiplies them together, and displays the result in the serial monitor!

Variables, Datatypes, Constants

In programs, we use variables and data structures to store data. Here we present some resources to learn about variables and data types.

Now different types of variables exist, they can store different things, and they use different amounts of memory to do that. These are called data types. We can also define constants in Arduino. It’s not necessary to understand these in great great detail, but it’s important to think about when you would use what kind of variable.

Sparkfun has a great tutorial on data types and why you might want to use certain types β†—.

Fun Arduino Projects to Inspire You!

There’s lots of things you can connect to an arduino to make super awesome things! Here’s a few just to get you thinking! We’ll cover many more in the class itself.

Here is some more info on Tensiometry β†— if you’re interested!