Hour of Code: Invent Your Own Spell!

hours of code

Looking for a magical Hour of Code lesson?

This set of beginner activities will get your students thinking about algorithms – a fancy word for a set of instructions to accomplish a task – and the importance of sequencing. Giving your students a solid foundation in these concepts will help them (and you!) develop a more concrete understanding before tackling more abstract concepts like variables, loops, syntax, etc.

Even though we’ve presented this as a whole lesson, we designed it to be “hacked” so you can adapt it to your own learning space. Want to print it out? Check out this Google docs version.

Don’t forget to share your spells with us and submit them to the Magic of Invention Challenge!

OVERVIEW: Students will learn the importance of sequencing and problem decomposition in giving instructions, two key Computational Thinking skills. They will use the Invention Cycle to design their own algorithms, or spells, that solve a problem in their daily life.

– What is an algorithm?
– Why does order matter when you give instructions?

Learners will….
– analyze and evaluate strengths and weaknesses of a basic instruction set.
– write an algorithm to solve a basic problem.
– design a functioning circuit that accomplishes a task

ESTIMATED TIME: 60-90 minutes
– Algorithm: Series of ordered steps taken to solve a problem or achieve some end.
– Sequence: A particular order in which related events, movements, or things follow each other.

This lesson can be adapted to align with one or more of the following standards (sourced from a similar lesson on Computational Thinking at Code.org):

ISTE Standards (formerly NETS)
1.a – Apply existing knowledge to generate new ideas, products, or processes.
1.c – Use models and simulation to explore complex systems and issues.
2.d – Contribute to project teams to solve problems.
4.b – Plan and manage activities to develop a solution or complete a project.
4.d – Use multiple processes and diverse perspectives to explore alternative solutions.

CSTA K-12 Computer Science Standards
CPP.L1:6-05. Construct a program as a set of step-by-step instructions to be acted out.
CT.L1:6-02. Develop a simple understanding of an algorithm using computer-free exercises.
CT.L2-01. Use the basic steps in algorithmic problem solving to design solutions.
CT.L2-06. Describe and analyze a sequence of instructions being followed.
CT.L2-08. Use visual representations of problem states, structures, and data.
CT.L2-12. Use abstraction to decompose a problem into sub problems.
CT.L2-14. Examine connections between elements of mathematics and computer science including binary numbers, logic, sets, and functions.

NGSS Science and Engineering Practices
3-5-ETS1-2. Generate and compare multiple possible solutions to a problem based on how well each is likely to meet the criteria and constraints of the problem.

Common Core Mathematical Practices
1. Make sense of problems and persevere in solving them.
2. Reason abstractly and quantitatively.
3. Construct viable arguments and critique the reasoning of others.
6. Attend to precision.
7. Look for and make use of structure.
8. Look for and express regularity in repeated reasoning.

– littleBits
– Paper
– Pencils/markers
– Optional (but more fun!): Basic craft materials (scissors, paper, rubber bands, tape, etc)

Students should have a basic knowledge of how littleBits work before beginning this lesson. Check out this Introduction lesson.

If you need an introduction to the Invention Cycle, refer to this lesson.

Students can work in teams or individually. If they are working in teams, here is a suggested role guide:
– Troubleshooter: this person is responsible for making sure the circuit works. If the circuit is not working as expected, this person unsnaps and resnaps the Bits together, wipes the bitSnaps, checks the battery, and volume levels.
– Provoker: this person encourages the group to test their idea at every stage.
– Ideas Person: this person is in charge of adding wacky ideas to the mix and encourages experimentation.
– Questioner: this person questions everything in every phase of the Invention Cycle. They constantly ask why and helps the group think critically about the decisions they make.

Duration: 60-90 minutes


STEP 1 : WARM UP: What’s in a spell? (10 min)

GOAL: Have students start thinking about the importance of order, sequencing, and detail when creating an algorithm.

TELL students that by the end of class, they will have designed a spell using littleBits.

DEFINE the word “spell” as a class once everyone is settled. Ask for any and all definitions.

EXPLAIN that a spell is a spoken word or form of words held to have magic power. For the witch or wizard, it is a set of instructions they use to cause a magical event to happen.

WRITE one of the following spells from Harry Potter where everyone can see. Ask students what goal it is supposed to accomplish and write it next to the spell. Then ask them to change the goal into something you can do in the room. Using words such as “goal”, “task”, “instructions”, etc will reinforce the analogy later.

Spells and goals:
– Goal: Moves objects
– Change the goal to: Move a book from point A to point B on a desk

– Goal: Repairs Things
– Change the goal to: Tape a piece of paper back together

– Goal: Cleans up messes
– Change the goal to: Put balls of paper back in trash

Wingardium Leviosa
– Goal: Makes on object fly
– Change the goal to: Throwing a soft object to a student

Rememberall (not a spell per se, but a good enchanted object to start from!)
– Goal: Helps you remember things
– Change the goal to: Set an alarm when you walk out the door or get up from your desk

EXPLAIN that as a group you are going to break this spell down into smaller steps that we would do without magic. Tell them they will give you will give me instructions, and you will follow them to accomplish the goal of the spell.

During this exercise, it is crucial that you take their instructions literally and allow them to self-correct as they watch your behavior. For example, if you are using Mobiliarbus and a student says push the book, push it off the desk – no one said to stop. Or if they say pick it up and put it over there, pick up another random object and put it on the floor.

ASK students why sequence was important in this exercise. Recall specific challenges they faced in accomplishing the task.

EXPLAIN that when you code, you have to give a computer a very specific set of ordered instructions to accomplish a task, just like a spell. This is called an algorithm.

TELL students that they are going to design their own algorithm spell to accomplish a task using littleBits.

EXPLAIN that littleBits are similar to computers: each Bit has a function. Bits won’t work if they aren’t in the right order.

BUILD a quick littleBits circuit: POWER + LED + BUTTON.

ASK students what is wrong with the circuit. Guide them to observe that since the button comes after the LED, it does not control the LED’s behavior.

STEP 2 : CREATE: A Spellbinding Problem! (5 min)

ASK students to write down a simple problem they would encounter in everyday life.

For example, remembering their lunch, dealing with a snooping sibling, finishing their homework, passing notes in class, etc.

STEP 3 : CREATE: Brainstorming (7 min)
hours of code1
Have students fill in this statement after they decide on their problem.

SHOW them a few examples of spells, or inventions, that other wizard inventors have created to solve problems of their own. Check out littlebits.cc/challenges or littlebits.cc/invent for inspiration

ASK students to brainstorm a solution to the problem. They can begin sketching or create a list of possible solutions.

HAVE students fill in this statement: My spell (what does it do?) by (how does it do it?) so (why is this a solution to problem?). For example: My spell helps you remember your lunch by turning on an alarm before you leave the house so I don’t forget it.

STEP 4 : CREATE: Prototyping (15-30 min)
hours of code2

TELL students they will use littleBits to bring their spell to life. Depending on the Bits you have, you can divide and distribute in small groups, hand out kits, or have students make a list of Bits they need if they are already familiar with the Bits available to them.

EXPLAIN that they will have 10-25 minutes to build their prototype, then 5 minutes to write or draw instructions so another wizard can recreate their spell. Each spell should also have a name.
STEP 5 : PLAY: Testing (5 min)

DIVIDE them into pairs (or groups of pairs) and have students test their spells. The tester should look at the instructions first, then test the invention.
STEP 6 : REMIX: Make improvements (5 min)

HAVE students make any changes to their spells based on the feedback they received. If you are short on time, skip this and ask students what they would change when they share.
STEP 7 : SHARE: Perform it in action (5-10 min)

ASK for volunteers to present their problem then perform their spell.
STEP 8 : SHARE: Reflection (5-10 min)

ASK students the following questions to assess their understanding:
– How is an algorithm similar to a spell? How is it different?
– Why is the order of instructions important? Can you think of any other processes where order is important? (e.g. equations and order of operations, scientific method, cooking, etc)
– Could you imagine another set of instructions to solve the same problem?

STEP 9 : EXTENSION: Take it further

CONNECT this activity to ELA by having students write or film a short story about their spell. Focus on analyzing and using the elements of a story.

REFINE spell instructions and have students upload their spells to the littlebits.cc/invent page. There’s a whole big inventor community who can’t wait to see them AND your students can focus on their technical writing skills. Once they are on the site, see if students can reproduce each others’ spells.

MORE IDEAS? Add them in the comments! How did you adapt this for your learning space?