Arduino Labs
Get started with Arduino with these labs.
C for Arduino
A sequence of simple sketches for illustrating the C programming language on the Arduino.
Exploring Color
An RGB LED works like a computer screen; it relies on how your eye detects color. Your eye has three types of color-sensitive cells (called cones). Each type is most sensitive to a particular color of light: red, green, or blue. We perceive different relative proportions of those colors as different colors. For example, yellow light triggers the red- and green-sensitive cells in a certain proportion so we perceive the color yellow. That fact allows us to fake “yellow” to the human eye by producing red and green in that same proportion. An RGB LED lets us produce approximately any color we want by varying the red, green, and blue channels individually. In this lab, you’ll play with colors and explore this effect.
Exploring Signals
The City of Oakland is embroiled in a power struggle: municipal electricity costs are sky-high! Mayor Jorry Brawn just read a report about LED street lights that use 35% less energy than standard High Pressure Sodium bulbs, and he wants to replace all of Oakland’s street lights with LED models. The LEDs will save the city almost a million dollars a year on energy costs alone! At Joan Queen’s house party last night, you met Mayor Brawn and told him about this great Arduino workshop you just took and (since all the professional engineers are working for Tesla these days) Mayor Brawn put you in charge of setting up this new system.
Many LEDs
In this lab, you’ll play with 8 LEDs in a row. Each LED can represent a “bit” and together form an 8 bit byte. You can use this array to show levels, for example, to show how loud an amplifier is, or to indicate the temperature.
Many Ways to Blink 1: Potentiometer to LED
This series of tutorials focuses on demonstrating the power of system thinking. We will start with the Potentiometer –> Arduino –> LED system you have seen in the beginning class. We will then switch out the inputs and the outputs and then change the code to adapt the input to the output. Throughout this whole series the system will have the same behavior. This is the input will control the blink rate of the output. To begin with we will go through the code you have seen before. This tutorial will focus on how the code is organized and how to see what the code is doing while it is running.
Many Ways to Blink 2: Light Sensor to LED
This tutorial shows you how to switch out the potentiometer for a light sensor. We will go through how to change the electronics and code to make this new system give you the same behavior as the Potentiometer to LED. The trick about this code is that the Light Sensor does not have the same input range as the potentiometer. As you saw before with the potentiometer, sensorValue can range from 0 to 1023. The light sensor resistance does not change as much as the potentiometer and so the range of . We will show you how to find this new range and update the code so it will have the same behavior as before
Many Ways to Blink 3: Light Sensor to Servo
In Tutorial 3 we are going to replace the LED with a servo and make it “blink”. What “blink” means in the case is that the servo will switch back and forth between two difference positions. A servo has a PWM interface so we will have to generate a PWM signal from the Arduino. You can click on the link to read more about PWM and how it works if you want to. The Uno can generate a PWM signal from pins 11,10,9,6,5, and 3. In this case we will be using pin 9. The other important thing using a servo is that is it easiest to use a library to control it. This prebuilt code means we can tell the servo to move to the 105 degree positon and not worry about exactly what PWM duty cycle is needed to do that. Conveniently, a library for exactly that comes built into Arduino. It is called Servo. To use the library we will have to add some lines of code to the sketch which you will see in the Code section.
Many Ways to Blink 4: Ultrasonic Distance Sensor to Servo
This tutorial replaces the Light Sensor with a Ultrasonic Distance Sensor. This sensor sends out high frequency sound pulses and times how long it takes for them to come back much like a bat does. We can then convert that time into a distance. The interesting thing about this sensor is that it produces a digital signal as opposed to an analog signal. This type of sensor also has a a library called the NewPing library. This library takes the digital signals coming from the ultrasonic sensor and converts them into a the duration between when the ultrasonic sensor sent a pulse and when it received it back. Working with distances is easier than working with times so the library defines conversion factors that will convert this duration into a distance. In this tutorial we will use the “US_ROUNDTRIP_CM” variable which is equal to 57us/cm. Since US_ROUNDTRIP_CM already defined by the NewPing library we do not need to define it in our code.
Many Ways to Blink 5: Ultrasonic Sensor to Computer
This tutorial turns your computer screen into one giant LED. You will be able to control the blink rate of you computer screen with the ultrasonic sensor. This is a little over kill :) but the point is to see your computer as an ouput block for the arduino. To do this we will use a new program called Processing. If you do not have it on your computer you should download and install it. Processing is the equivalent of Arduino but it works on the Computer as opposed to a microcontroller.