Lab 0 β Introduction to Arduino
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!
Basic Arduino Getting Started
A general overview of the Arduino platform.
Arduino IDE
Overview of the desktop programming environment, note this also contains a small version of the Blink tutorial.
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.
Hello World w/ Arduino
Introduction to using the Arduino Serial Monitor and printing information to the terminal.
Printing Variables
Note that you can also print the value of a variable in many formats!
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.
List of all Arduino Data Types
Here you find documentation on all the arduino variable types and how to use them.
Constants in Arduino
Constants cannot be changed without re-uploading the program. But they’re very useful in defining things like pin numbers and more!
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.
Save the Elephants!
Mahout is an organization focused on conservation of Asian elephants. They put collars on the elephants to help track them and also understand their behvaioral patterns! This is one of my favorite Arduino projects.
Irrigation, and Crop Monitoring
Challenge agriculture uses tensiometry to measure the water content of soil for smart irrigation. They do multi-level imaging of the soil, for irrigation monitoring, prevention of soil degradation and road cracking, and even more!
Arduino at the Edge of Space!
Here’s a super fun project, buidling an Arduino weather balloon with a datalogger! Weather balloons are super cool because they allow scientists to study weather at atmospheric patterns.
Medical Devices
MySignals is an IoT development platform for medical devices powered by Arduino. It has a number of sensors such as SPO2, Temperature, EMG, ECG, Blood Pressure and more. And has the ability to add custom sensors all streamed to an online platform. Likely not avaliable anymore to data privacy concerns, it is an example of how Arduino could make medical devices more accessible.
Here is some more info on Tensiometry β if you’re interested!