LESSON PLANS
Arduino Blink Challenge
By submitting this form, you are giving IEEE permission to contact you and send you email updates about free and paid IEEE educational content.
This lesson explores how computer and software engineers work to solve the challenges of a society, such as providing systems for turning lights on and off automatically. Students work in teams to set up and program an Arduino board to “blink” (i.e. turn a light on and off at a 5 second on and 2 second off interval).
Age Levels: 14 – 18
Required Materials
Use the programmed Arduino board and LED bulbs for testing. See the “Testing Materials and Process” Section for a Step-by-Step Arduino Setup Tutorial.
Step-by-Step Arduino Setup Tutorial (for Windows)
This tutorial explains how to connect your Arduino board to the computer and upload your first sketch. This is provided and available online by Arduino at http://arduino.cc/en/Guide/HomePage. These instructions apply to the Windows environment, but Arduino works on Mac OS X and Linux and the website provides step-by-step instructions for all operating systems.
Design Challenge
You are part of a team of engineers given the challenge of using Arduino to make a light blink on for 5 seconds and off for 2. The instructions and code on the Student Worksheets will help you see how to program the Arduino to blink for one second on and one second off.
Criteria
Constraints
Use only the materials provided.
Extension Idea
Require students to make the Arduino blink in the pattern of S-O-S…or have them select three other activities (run a fan, make a stoplight, etc.).
Student Reflection (engineering notebook)
The lesson can be done in as little as 1 class period for older students. However, to help students from feeling rushed and to ensure student success (especially for younger students), split the lesson into two periods giving students more time to brainstorm, test ideas and finalize their design. Conduct the testing and debrief in the next class period.
Divide into teams
Review the challenge and criteria constraints
Brainstorm possible solutions (sketch while you brainstorm!)
Choose best solution and build a prototype
Test then redesign until solution is optimized
Reflect as a team and debrief as a class
Beyond Flashing Lights
If you have completed the Arduino Blink Challenge, there are many other applications for using an Arduino board that you can try on your own, as a team, in the classroom, or on your own time. You can also find advanced tutorials at http://arduino.cc/en/Tutorial/HomePage to show you how to read a switch, read a potentiometer, use a pushbutton to control an LED, play tones on multiple speakers, make an LED bar graph, send a text string, or even output the values from a barometric pressure sensor as a web page.
The following are some sample ideas so you can see how versatile your new computing skills are!
Control Sensors
Try controlling an external sensor with your Arduino. You can sample air for pollution, identify how bright an area is, set up a flood alarm with a water sensor, or attach a motion detector. Or, consider using the Arduino to control sensors that measure electromagnetic Fields, sample air for humidity levels, take the temperature, identify if a gas is present in the air, or gather data from an anemometer that measures wind speed. You can even attach a barcode scanner (which simulates a keyboard) or a keyboard to the Arduino.
Visual and Audio Applications
Your arduino can be set up to manage a camera system, and control photography settings. This can be done with most equipment, including Nikon, Canon, Sony, Minolta, Olympus and Pentax cameras. You can even attach a barcode scanner (which simulates a keyboard) or a keyboard to the Arduino.
Motors and Robotics
Arduino is a great tool for controlling motors and robotics. Try connecting DC motors or stepper motors. You can control a highly accurate stepper motor using a potentiometer with an Arduino.
Community of Developers
There is a growing community of Arduino application developers who share code, ideas, and example. Additional documentation has been created by the Arduino community on the publicly-editable playground wiki at http://playground.arduino.cc.
Open Source Computing
Arduino is an open-source physical computing platform based on a simple microcontroller board, and a development environment for writing software for the board. Arduino can be used to develop interactive objects, taking inputs from a variety of switches or sensors, and controlling a variety of lights, motors, and other physical outputs. Arduino projects can be simple – – such as turning on and off a light — or very complex. The boards can be assembled by hand or purchased preassembled; the open-source software can be downloaded for free. The Arduino software runs on Windows, Macintosh OSX, and Linux operating systems.
Computer Programming
Computer programming (often shortened to programming or coding) is the process of designing, writing, testing, debugging, and maintaining source code of computer programs. The code can be written in many different programming languages. Programming is basically a set of instructions that a computer or other device uses to perform a task — it might be turning on a light, opening a door, or writing a document.
Arduino Development Environment
The Arduino development environment or software contains a text editor for writing code, a message area, a text console, a toolbar with buttons for common functions, and a series of menus. It connects to the Arduino hardware to upload programs and communicate with them. Software written using Arduino is called a “sketch.” These sketches are written in the text editor. Sketches are saved with the file extension .ino. There are features for cutting/pasting and for searching/replacing text. The message area gives feedback while saving and exporting and also displays errors. The console displays text output by the Arduino environment including complete error messages and other information. The bottom right hand corner of the window displays the current board and serial port.
Note: Some content and images on this page are derived from Arduino.cc via their recommended Arduino getting started guide (http://arduino.cc/en/Guide/HomePage). The text of the Arduino getting started guide is licensed under a Creative Commons Attribution-ShareAlike 3.0 License. Code samples in the guide are released into the public domain.
Internet Connections
Recommended Reading
Writing Activity
Write an essay or a paragraph that identifies three major products or systems that have been overwhelmingly impacted by computer programming.
Note: Lesson plans in this series are aligned to one or more of the following sets of standards:
CONTENT STANDARD A: Science as Inquiry
As a result of activities, all students should develop
CONTENT STANDARD B: Physical Science
As a result of their activities, all students should develop an understanding of
CONTENT STANDARD E: Science and Technology
As a result of activities in grades 5-8, all students should develop
CONTENT STANDARD F: Science in Personal and Social Perspectives
As a result of activities, all students should develop understanding of
CONTENT STANDARD G: History and Nature of Science
As a result of activities, all students should develop understanding of
CONTENT STANDARD A: Science as Inquiry
As a result of activities, all students should develop
CONTENT STANDARD B: Physical Science
As a result of their activities, all students should develop understanding of
CONTENT STANDARD E: Science and Technology
As a result of activities, all students should develop
CONTENT STANDARD F: Science in Personal and Social Perspectives
As a result of activities, all students should develop understanding of
CONTENT STANDARD G: History and Nature of Science
As a result of activities, all students should develop understanding of
Students who demonstrate understanding can:
Engineering Design
Students who demonstrate understanding can:
Engineering Design
Students who demonstrate understanding can:
Computational Thinking:
Collaboration:
Computing Practice & Programming:
Computers & Communications Devices:
Computational Thinking:
Collaboration:
Computing Practice & Programming:
Computers & Communications Devices:
Collaboration:
The Nature of Technology
Technology and Society
Design
Abilities for a Technological World
The Designed World
Engineering Teamwork and Planning
You are part of a team of engineers given the challenge of using Arduino to make a light blink on for 5 seconds and off for 2. The instructions and code below will help you see how to program the Arduino to blink for one second on and one second off.
Research Phase
Read the materials provided to you by your teacher. If you have access to the internet ahead of the activity, explore the Arduino website and become familiar with the logic of the programming code.
Building the Circuit
To build the circuit, attach a 220-ohm resistor to pin 13. Then attach the long leg of an LED (the positive leg, called the anode) to the resistor. Attach the short leg (the negative leg, called the cathode) to ground. Then plug your Arduino board into your computer, start the Arduino program, and enter the code below. Note: Most Arduino boards already have an LED attached to pin 13 on the board itself. If you run this example with no hardware attached, you should see that LED blink.
You may also set up your blinking light using a breadboard as in the image above. In this case, you’ll use the connectors to link the Arduino to the breadboard and make a complete circuit by having another connector going back to Arduino. You would need to include a separate light on the breadboard too. You can do this lesson either way…with or without the breadboard — it just depends on what materials you have provided to you and if your team wishes to gain some experience on the breadboard.
Note: Some content and images on this page are derived from Arduino.cc via their Arduino getting started guide (http://arduino.cc/en/Guide/HomePage)
Schematic
This illustration or schematic shows how the circuit for the light works in the Arduino.
Code
In the program below, the first thing you do is to initialize pin 13 as an output pin with the line
pinMode(13, OUTPUT);
In the main loop, you turn the LED on with the line:
digitalWrite(13, HIGH);
This supplies 5 volts to pin 13. That creates a voltage difference across the pins of the LED, and lights it up. Then you turn it off with the line:
digitalWrite(13, LOW);
That takes pin 13 back to 0 volts, and turns the LED off. In between the on and the off, you want enough time for a person to see the change, so the delay() commands tell the Arduino to do nothing for 1000 milliseconds, or one second. When you use the delay() command, nothing else happens for that amount of time.
/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.
This example code is in the public domain.
*/
// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}
// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}
Reflection
Complete the reflection questions below:
1) What challenges did you have, if any, to programming the Arduino to blink on and off at 1 second intervals? How did you resolve any challenges you encountered?
2) Were you able to adjust the code to change the intervals to 5 seconds on and 2 seconds off?
3) Do you think that this activity was more rewarding to do as a team, or would you have preferred to work alone on it? Why?
4) What do you think about the Arduino? Was it a good way for you and your team to explore basic computer programming?
5) How complicated or different do you think code would be to provide instructions to a cell phone to play a particular ringtone?
6) Do you think that stoplights use computer programming to provide a pattern for lights changing at intersections? How do you think stoplights were coordinated prior to computer technology?