Spooky Lights – Piper

SPOOKY LIGHTS

PIPER MAKE EDUCATOR RESOURCES SERIES

To do this project, you will need a Piper Make Starter Kit. Get yours here:

Simulate the flickering light of a candle using NeoPixels.

To get started, head to Piper Make and hit this icon:

Time: 30 minutes

Age Range: 8+

Difficulty: Beginner

In this project, students build and program NeoPixel LED's using loops, variables, and actions.

Note: There are step by step instructions for the students to follow in the tutorials included in each project on Piper Make. These provide directions both for writing code and for building the electronic circuits. The tutorials are well-defined and most students will be able to follow them with little assistance required.

LEARNING OBJECTIVES

Students will:

 

  • Practice breadboarding and wiring
  • Review and understand computational concepts of:
    • loops: running the same sequence multiple times.
    • sequence: identifying a series of steps for a task
  • Demonstrate computational thinking core concepts, including:
    • Algorithm Design by creating an ordered series of instructions for solving similar problems or for doing a task, such as turning a light off and on in the right order.
    • Simulation by developing a program to imitate the flickering of a candle.
  • Decompose problems into smaller, manageable tasks which may themselves be decomposed.
  • Test and debug a program or algorithm to ensure it accomplishes the intended task.

STANDARDS ALIGNMENT

CSTA's K-12 Standards 

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended. Subconcept: Program Development; Practice 6.1, 6.2

CCSS ELA

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

World-Class Instructional Design and Assessment (WIDA) English Language Proficiency Standards

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

California's K-12 Computer Science Standards

3-5.CS.3: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies.

3-5.AP.11: Create programs that use variables to store and modify data.

3-5.AP.12: Create programs that include events, loops, and conditionals.

3-5.AP.13: Decompose problems into smaller, manageable tasks which may themselves be decomposed.

3-5.AP.14: Create programs by incorporating smaller portions of existing programs, to develop something new or add more advanced features.

3-5.AP.17: Test and debug a program or algorithm to ensure it accomplishes the intended task.

Common Core English Language Arts

CCSS.ELA.L.W.3.8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

CCSS.ELA.L.W.3.10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

California English Language Development Standards

CA ELD.3.C.11: Supporting own opinions and evaluating others’ opinions in speaking and writing

CA ELD.3.C.12: Selecting and applying varied and precise vocabulary and language structures to effectively convey ideas

Michigan Integrated Technology Competencies for Students (MITECS)

1B-CS-03: Determine potential solutions to solve simple hardware and software problems using common troubleshooting strategies. Subconcept: Troubleshooting; Practice 6.2

1B-AP-09: Create programs that use variables to store and modify data. Subconcept: Variables; Practice 5.2

1B-AP-10: Create programs that include sequences, events, loops, and conditionals. Subconcept: Control; Practice 5.2

1B-AP-11: Decompose (break down) problems into smaller, manageable subproblems to facilitate the program development process. Subconcept: Modularity; Practice 3.2

1B-AP-12: Modify, remix, or incorporate portions of an existing program into one’s own work, to develop something new or add more advanced features. Subconcept: Modularity; Practice 5.3

1B-AP-15: Test and debug (identify and fix errors) a program or algorithm to ensure it runs as intended. Subconcept: Program Development; Practice 6.1, 6.2

Michigan English Language Arts

Michigan ELA, Grade 3-8, Research, 8: Recall information from experiences or gather information from print and digital sources; take brief notes on sources and sort evidence into provided categories.

Michigan ELA, Grade 3-8, Range of Writing, 10: Write routinely over extended time frames (time for research, reflection, and revision) and shorter time frames (a single sitting or a day or two) for a range of discipline-specific tasks, purposes, and audiences.

WIDA English Language Development

ELD-SI.K-3.Argue:

  • Ask questions about others’ opinions
  • Support own opinions with reasons
  • Clarify and elaborate ideas based on feedback
  • Defend change in one’s own thinking
  • Revise one’s own opinions based on new information

 

ELD-SC.2-3.Argue.Interpretive:

  • Interpret scientific arguments by
  • Identifying potential evidence from data, models, and/or information from investigations of phenomena or design solutions
  • Analyzing whether evidence is relevant or not
  • Distinguishing between evidence and opinions

Science Texas Essential Knowledge & Skills Grade 3

(b)(2) Scientific investigation and reasoning. The student uses scientific practices during laboratory and outdoor investigations. The student is expected to:
(A) plan and implement descriptive investigations, including asking and answering questions, making inferences, and selecting and using equipment or technology needed, to solve a specific problem in the natural world;

(b)(3) Scientific investigation and reasoning. The student knows that information, critical thinking, scientific problem solving, and the contributions of scientists are used in making decisions.

Science Texas Essential Knowledge & Skills Grade 4

(a)(1)(A) Within the physical environment, students know about the physical properties of matter including mass, volume, states of matter, temperature, magnetism, and the ability to sink or float. Students will differentiate among forms of energy including mechanical, light, sound, and thermal energy. Students will explore electrical circuits and design descriptive investigations to explore the effect of force on objects.

(b)(3) Scientific investigation and reasoning. The student uses critical thinking and scientific problem solving to make informed decisions. The student is expected to:

    (A) analyze, evaluate, and critique scientific explanations by using evidence, logical reasoning, and experimental and observational testing;

    (B) represent the natural world using models such as the water cycle and stream tables and identify their limitations, including accuracy and size; and

    (C) connect grade-level appropriate science concepts with the history of science, science careers, and contributions of scientists.

Science Texas Essential Knowledge & Skills Grade 5

(a)(1) In Grade 5, scientific investigations are used to learn about the natural world. Students should understand that certain types of questions can be answered by investigations and that methods, models, and conclusions built from these investigations change as new observations are made. Models of objects and events are tools for understanding the natural world and can show how systems work. They have limitations and based on new discoveries are constantly being modified to more closely reflect the natural world.

(a)(3) Recurring themes are pervasive in sciences, mathematics, and technology. These ideas transcend disciplinary boundaries and include patterns, cycles, systems, models, and change and constancy.

ELA Texas Essential Knowledge & Skills Grade 3

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) speak coherently about the topic under discussion, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively;

    (D) work collaboratively with others by following agreed-upon rules, norms, and protocols; and

    (E) develop social communication such as conversing politely in all situations.

ELA Texas Essential Knowledge & Skills Grades 4 & 5

(b) (1)Developing and sustaining foundational language skills: listening, speaking, discussion, and thinking--oral language. The student develops oral language through listening, speaking, and discussion. The student is expected to:

    (A) listen actively, ask relevant questions to clarify information, and make pertinent comments;

    (B) follow, restate, and give oral instructions that involve a series of related sequences of action;

    (C) express an opinion supported by accurate information, employing eye contact, speaking rate, volume, enunciation, and the conventions of language to communicate ideas effectively; and

    (D) work collaboratively with others to develop a plan of shared responsibilities.

(b)(13) Inquiry and research: listening, speaking, reading, writing, and thinking using multiple texts. The student engages in both short-term and sustained recursive inquiry processes for a variety of purposes. The student is expected to:

    (A) generate and clarify questions on a topic for formal and informal inquiry;

    (B) develop and follow a research plan with adult assistance;

    (C) identify and gather relevant information from a variety of sources;

    (D) understand credibility of primary and secondary sources;

    (E) demonstrate understanding of information gathered;

    (F) differentiate between paraphrasing and plagiarism when using source materials;

    (G) develop a bibliography; and

    (H) use an appropriate mode of delivery, whether written, oral, or multimodal, to present results.

§74.4. English Language Proficiency Standards

(c) Cross-curricular second language acquisition essential knowledge and skills.

(3) Cross-curricular second language acquisition/speaking.

(D) speak using grade-level content area vocabulary in context to internalize new English words and build academic language proficiency;

(E) share information in cooperative learning interactions;

(F) ask and give information ranging from using a very limited bank of high-frequency, high-need, concrete vocabulary, including key words and expressions needed for basic communication in academic and social contexts, to using abstract and content-based vocabulary during extended speaking assignments;

(G) express opinions, ideas, and feelings ranging from communicating single words and short phrases to participating in extended discussions on a variety of social and grade-appropriate academic topics;

(H) narrate, describe, and explain with increasing specificity and detail as more English is acquired;

CONCEPTS

Students will use loops, actions, and variables to program an output, the NeoPixel LED's.

PARTS

Raspberry Pi Pico, breadboard, charging cable, 3x M2M Jumper Wires, 5x NeoPixel LED's

GPIO SETUP

NeoPixel's Input to GP15

OVERVIEW OF STEPS

Step 1: Flickering Pumpkins!

In this very short tutorial, we are going to have a little fun using our NeoPixels to simulate a flickering light like a candle would make.

Are you ready? Click NEXT to get started!

Step 2: Gather your stuff

You will need:

  • Pico and Breadboard
  • 3 M2M Jumper wires
  • 5 NeopPixel LEDs

Step 3: Build the circuit

This circuit is very similar to the one you built in Party Lights.

The first thing we are going to do is add the NeoPixels to the Breadboard.

It works best if you spread the leads of the NeoPixel out a little bit first. Look carefully at the image below. Make sure that as you are connecting the NeoPixels to the breadboard, they are oriented correctly!

The longest lead is going to go into the ground rail at the top of the breadboard. The other middle lead will connect to the 5V rail at the top of the breadboard. The leftmost lead will connect into a column on the breadboard, and the rightmost lead will connect to a different breadboard column.

Repeat this process for each of the remaining NeoPixels. Remember that the output of one NeoPixel connects to the input of the next Neopixel.

Then, use a jumper wire to connect the input of the first NeoPixel's Input to GP15.

Next, connect the top power rails. Use a jumper wire to connect the top ground rail to a ground pin on the Pico. Use another jumper to connect the positive rail at the top of the breadboard to 5V.


Once your circuit is complete, click NEXT.

Step 4: Add the code

The first thing that we need to do is create a repeat forever loop. Grab a start block from the Chip menu and place it on the workspace. Since we are using NeoPixels, grab a setup neopixels block from the Actions menu and connect if to the start block. Change the pin to GP15, and change the number of pixels to 5. Then, grab a repeat forever block from the Loops menu and connect it to the setup neopixels block.

Our goal is to simulate the light that comes from a candle flame. Looks carefully at the flame below. The light from a flame varies randomly, and three things about it can vary:

  • - Color
  • - Brightness
  • - How quickly the two things above change

 

Do this again: create a "bright" variable and a "delay" variable, and add their set blocks to the inside of the repeat forever block:

Step 5: Making a random delay

Let's build the random delay that we will use to make our spooky lights "flicker". We want our flicker to happen every 0.05 to every 0.1 seconds.

The problem is that the random integer block only outputs an integer. An integer is a positive or negative whole number - that means that we can't use that block to make a number with a decimal.

How do we fix that?

We pick a larger random integer, and then we divide it to make it much smaller!

If we pick numbers that are 1000 times bigger, then we can just divide by 1000 and delay by that much!

Grab the 0.5 block in the wait at the bottom of the repeat forever block and drag it out - set it to the side. Grab a _ + _ block from the Logic menu and place it into the repeat forever block's wait input. Change the + (plus) to a ÷ (divide by). Then, put the 0.5 block into the right side of the _ ÷ _ block.

Then, grab a delay block from the Variables menu and place it into the left side of the _ ÷ _ block. Change the 0.5 to 1000:

Then, grab a delay block from the Variables menu and place it into the left side of the _ ÷ _ block. Change the 0.5 to 1000:

Now, grab a random integer block from Values and put it into the set delay to block. Since we want delay values from 0.05 to 0.1, we need to multiply both of those numbers by 1000. If you do that, you get 50 and 100. Change the numbers in the random integer block to 50 and 100:

Step 6: Random colors

Now that our random delay is ready, let's build a random color that we can set all of the NeoPixels to.

Grab a set all neopixels to block from Actions and connect it below the set delay to block. Grab the color block inside of the set all neopixels to block and drag it to the trash can to delete it.

Grab a color hue block from Values and place it into the set all neopixels to block. Then, grab the 0 and 100 blocks from inside the color hue block and drag them to the trash can.

Grab a hue block from Variables and place it into the hue input of the color hue block. Then, grab a bright block from Variables and place it into the brightness input:

We're getting closer! Grab an update neopixels block from Actions and connect it below the set all neopixels to block.

Now we just need random integers for hue and brightness!

We know that brightness ranges from 0 to 100, so grab a random integer block from Values and place it into the set bright to block. Change the 1 to 30:
Now we just need a random number for the hue. But what numbers do we use? Take a look at the image below. These are the values that represent different hues. You can see that if we use numbers between 65 and 80, we will get color hues from yellow-orange to orange-red:
Grab another random integer block from Values and place it into the set hue to block. Change the 1 to 65, and change the 100 to 80:

Step 7: Try it out!

Click CONNECT. Select your Pico from the list of devices.

Be careful! NeoPixels can be really bright, so don't stare directly into them!

Click START to run your code.

How does it look? Not a bad looking flickering flame, right?

How can you modify it? Can you make a green flame, or a blue one? Can you speed it up or slow it down? Use your imagination!

If you want to place your project in a Pumpkin, be sure to protect it by placing it in a plastic zipper bag first! You can also use a piece of plain paper over the top of the NeoPixels to diffuse the light to make it even more realistic!

Step 8: You've Finished!

Click EXIT to return to the menu and start your next coding challenge.