Lesson 8: Color LEDs

45 minutes

Overview

In this lesson, students learn how to use the 10 color LEDs on the Circuit Playground. Students will control the color and intensity of each LED, then use what they have learned to program light patterns to create a light show on their Circuit Playground.

Question of the Day: How can you use the colored LEDs in an app?

CSTA K-12 Computer Science Standards (2017)
    • 2-AP-11 - Create clearly named variables that represent different data types and perform operations on their values.
    • 2-AP-13 - Decompose problems and subproblems into parts to facilitate the design, implementation, and review of programs.
    • 2-AP-16 - Incorporate existing code, media, and libraries into original programs, and give attribution.
    • 2-AP-19 - Document programs in order to make them easier to follow, test, and debug.
    • 2-CS-02 - Design projects that combine hardware and software components to collect and exchange data.

Agenda

Objectives

Students will be able to:
  • Use the color LED block to individually control each color LED

Preparation

  • Prepare a board and USB cable for each pair of students
  • Check the "Teacher's Lounge" forum for verified teachers to find additional strategies or resources shared by fellow teachers

Links

Heads Up! Please make a copy of any documents you plan to share with students.

For the teachers
For the students

Teaching Guide

Warm Up (5 minutes)

Journal

Prompt: What is a list? What do you use lists for?

Share Out: Once students have had time to write down their own thoughts, have them share out with the whole class. Work as a class to try to get an understanding of what a list is.

Discussion Goal: While the types of lists students come up with vary from class to class, the two main characteristics of lists that students should understand is that they usually are comprised of items of the same type (tasks to complete, names of people, song titles, grocery items, etc.) and that they have an order. Some common types of lists include a to-do list, a class roster, a playlist, or a grocery list.

Remarks

Lists are useful in programming too when we want to access the same type of item in a certain order. For example, the small colored LEDs in a ring around the center of your circuit playground can be represented as a list of LEDs, with a starting LED and an ending LED. Today we’re going to learn how to program these LEDs, and we’ll use a list to access each individual LED.

Activity (35 minutes)

Transition: Send students to Code Studio

Teaching Tip

Guide to Programming Levels: Additional guidance for programming levels is provided in the CSD Guide to Programming Levels. This document includes strategies and best-practices for facilitating programming levels with students.

Troubleshooting Devices: If student devices aren't able to connect, they can click the Help and Tips tab and then access the Maker Setup page (click the image to see more). This will let them re-reconnect their board to App Lab.

If students continue to have issues, refer to the Troubleshooting section of our Maker Support Article

Discussion Goal: Students may be able to guess the behavior of the code, but they may be slightly off in predicting which lights will light up. There isn't a clear orientation on the circuit playground, but students should be able to "work backwards" to determine which lights are which. Students may also notice that the lights start with 0, which is the "first" light on the board.

Content Corner

List Terminology: A list in javascript is formally called an array. The colorLEDs[x] block uses an array to access each LED. The number inside the [square brackets] is called the index. We might say colorLEDs[0] represents the LED at index 0, or colorLEDs[5] represents the LED at index 5.

Arrays are discussed in more depth in a later lesson and students do not need to have a strong understanding of arrays by the end of this lesson. At a bare minimum, students should understand that the “first” LED starts at index 0, and the “last” LED is at index 9.

Assessment Opportunity

Formative Assessment: This level can be used as a formative assessment. A rubric is provided in the level, and written feedback can be given to students. Click here to learn more about giving feedback to students.

Wrap Up (5 minutes)

Journal

Prompt: LEDs are used as output in many devices that we use every day. Try to think of at least one device that uses an LED and describe how it helps make the device more usable or communicates with the user.

Discussion Goal: Students should make connections between today’s lesson and devices they use outside of class. Some examples may include:

  • A washing or drying machine that lights up to indicate when clothes are finished
  • A credit card machine that uses different colored LEDs to indicate how a transaction is processing
  • Any device that uses a red light to indicate an error
  • Devices that turn on an LED when in the dark to make the device easier to use
Creative Commons License (CC BY-NC-SA 4.0).

This work is available under a Creative Commons License (CC BY-NC-SA 4.0).

If you are interested in licensing Code.org materials for commercial purposes contact us.