← Back to Library
Lesson PlanFreeEN

C3: Events - Event Handlers, Part 1

Students will review their previous programming using events. They will learn about how to use When blocks in Blockly to create event handlers for Dash and Dot. They will use Blockly preset programs and Challenge Cards to practice their new skills.

Gr. 2–2
C3: Events - Event Handlers, Part 1

Lesson

Overview

Description

Students will review their previous programming using events. They will learn about how to use When blocks in Blockly to create event handlers for Dash and Dot. They will use Blockly preset programs and Challenge Cards to practice their new skills.

Objectives

  • understand what problems are best solved with event handlers via the When block in Blockly

  • use event handlers to revise code and complete coding challenges in an iterative process

Before the Lesson

Prior Experience

It is recommended that students complete:

  • Level A-B Lessons: All

  • Level C: Lessons 1-2

  • [Optional] Level A-B Challenge Cards: All

  • [Optional] Level C Challenge Cards: C 1.1-1.3

You can purchase our Learn to Code Challenge Card sets and Curriculum Guide here: https://store.makewonder.com/#/education

Preparation

  • Fully charge the tablets and robots.

  • Install the Wonder Workshop Blockly app on each tablet.

Review

Events

  1. What are event handlers?

    • Sample response: “Event handlers allow the code to listen or wait for multiple events while the program is running.The code under each event handler only runs when that event occurs.”

  2. Why do we need event handlers?

    • Sample response: “Event handlers let us change what happens in our program while it is still running.”

  3. Why are event handlers important in video games?

    • Sample response: “Event handlers are important to video games because they tell the characters on the screen to jump or run when we press a specific button.”

Code.org Connections (Optional)

  1. Show Code.org’s video about events.

  2. After watching the video, ask:

    • “What is an event?” (Sample response: “An event is an action that causes something to happen.”)

    • “Why would you use an event handler?” (Sample response: “When you want to change the program while it is running.”)

Code.Org Connections [Optional]

Video player coming soon

Direct Instruction

Introduction

  1. Open the Blockly app and go to the Control menu. Then select a Wait For block and say, “An event is an action that causes something to happen. We have used Wait For blocks with Dash and Dot. What kinds of events can Dash and Dot sense?”

  • Sample response: “Dash and Dot can sense sounds and movements.”

  • Go to the Start menu and tap the When block. Say, “Now we are going to make event handlers with the Whenblock. What do you think will happen when we use When blocks in our code?”

    • Sample response: “The code under the When block will play when Dash’s Top Button is pressed.”

Quick Check

  • What is an event? (Sample response: “An event is an action that causes something to happen.”)

  • What block are we going to use to make event handlers with Dash and Dot? (Sample response: “We are going to use the When block.”)

Guided Practice

Activity: Loopy Shapes

  1. In the Blockly app, go to the menu at the top left of the screen.

  2. Go to the Create New Project menu and select the Loopy Shapes preset program. Then tap “create.”

    Loopy Shapes
  3. Play the program and press Dash’s Button 1 (i.e., the orange button with 1 dot). Ask students, “What did you notice?”

    • Sample response: “Dash did something different when you pressed Button 1.”

  4. Ask students, “Where is the When block that helps Dash wait for an event?”

    • Select a student to point out the When block. Then say, “This is the event handler in the program. It helps Dash wait for Button 1 to be pressed. Then the code under the When block starts.”

  5. Ask, “How did events change the code?”

    • Have students take turns sharing their guesses.

    • Then say, “Since event handlers are always looking for events to happen, using them allows us to change how the program acts even after we press start. For example, if we ran our program without the When block, Dash would only drive forward and turn left four times. However, since we used an event handler (When Dash Button 1), we were able to change the direction Dash turned. Using event handlers allows us to code Dash to perform more tasks.”

  6. Have student volunteers take turns changing the event in the When block. Run the program each time so students can observe how Dash’s behavior changes.

    • If time permits, you can select student volunteers to add more When blocks to the program.

Quick Check

  • Why should we use event handlers in our programs? (Sample response: “We should use event handlers so we can change our program while it is running.”)

  • What is an event? (Sample response: “An event is an action that causes something to happen.”)

Independent Practice

Instructions

Have students work on the following activities in small groups (ideally 2-3 students per robot).

Encourage students to share tablet and robot time. Have them establish and rotate through roles such as:

  • Lead Programmer: Holds the tablet and manipulates the code.

  • Robot Wrangler: Retrieves and resets the robot after every program attempt.

  • Documentarian: Records group results, thoughts, and progress. Illustrates group designs and ideas.

When students work together while coding, they're able to help each other identify mistakes and develop creative solutions!

Loopy Shapes Extension

  1. Have students use the Wonder Journal: Dash Planning and/or General Planning worksheets to design ways to add to or alter the Loopy Shapes preset program. They can:

    • Change the sequence.

    • Add more or change the When blocks (i.e., event handlers).

    • Add lights, sounds, or animations to the loops.

  2. After they finish revising the program, have students:

    • Complete a Wonder Journal: Reflection worksheet.

    • Take a screenshot of their Blockly code.

    • Take a video of Dash while the code is running.

Challenge Cards (Optional)

  1. You can purchase our Learn to Code Challenge Card sets and Curriculum Guide here: https://logicsacademy.com/store/

  2. Have students complete the following Challenge Cards:

    • C 2.1: Connect the Dots

    • C 2.2: The Dot Show

    • C 2.3: It’s Your Turn!

  3. For each challenge, encourage students to:

    • Use the Wonder Journal: Dot Planning and/or General Planning worksheet to discuss how they can complete the challenge.

    • Review the Troubleshooting and Problem Solving & Debugging worksheet if they run into any problems with their code.

  4. After they finish each challenge, have students:

    • Complete a Wonder Journal: Reflection worksheet.

    • Take a screenshot of their Blockly code.

    • Take a video of Dot while the code is running.

    • Update their Challenge Card Checklists.

Wrap Up

Student Presentations

  1. Have student groups take turns sharing one of their programs with the class. Encourage them to:

  2. Explain their design thinking (e.g., "We wanted to add an event handler to our program so it would be more interesting").

  3. Share any obstacles and difficulties they overcame during the activity (e.g., "We weren’t sure how to make Dash respond to a different button, but then we added a When Dash Button 2 block").

  4. Encourage students to ask each other how they accomplished different objectives and give each other feedback on their programs. Possible questions/feedback includes:

    • "How did you (add a new event handler)?"

    • "I like how you (used what you learned before to add repeats to your events)."

Follow-Up Questions/Discussion

  • How did event handlers help you with your program?

  • Why are event handlers important when using a phone? (Sample response: “Event handlers are important because phones must constantly be looking to see if we press a button or tap on the screen.”)

Assessment

  • Use our Evaluation Rubric to review students' work and presentations.

  • [Optional] Share your students' work with the world using @logicsacademy and #dashanddot!

Educational Standards

CSTA

CSTA

  • 1A-AP-10: Develop programs with sequences and simple loops, to express ideas or address a problem.

  • 1A-AP-11: Decompose (break down) the steps needed to solve a problem into a precise sequence of instructions.

  • 1A-AP-12: Develop a plan that describes a program’s sequence of events, goals, and expected outcomes.

  • 1A-AP-14: Debug (identify and fix) errors in an algorithm or program that includes sequences and simple loops.

  • 1A-AP-15: Using correct terminology, describe steps taken and choices made during the iterative process of program development.

ISTE

ISTE

  • 4d: Exhibit a tolerance for ambiguity, perseverance, and the capacity to work with open-ended problems.

  • 5a: Formulate problem definitions suited for technology-assisted methods such as data analysis, abstract models and algorithmic thinking in exploring and finding solutions.

  • 6b: Create original works or responsibly repurpose or remix digital resources into new creations.

  • 7c: Contribute constructively to project teams, assuming various roles and responsibilities to work effectively toward a common goal.

NGSS

NGSS

  • K-2-ETS1-1: Ask questions, make observations, and gather information about a situation people want to change to define a simple problem that can be solved through the development of a new or improved object or tool.

  • K-2-ETS1-2: Develop a simple sketch, drawing, or physical model to illustrate how the shape of an object helps it function as needed to solve a given problem.

Common Core

Common Core

  • CCSS.ELA-LITERACY.W.2.8: Recall information from experiences or gather information from provided sources to answer a question.

  • CCSS.ELA-LITERACY.SL.1.1: Participate in collaborative conversations with diverse partners about grade 1 topics and texts with peers and adults in small and larger groups.

  • CCSS.ELA-LITERACY.SL.1.2: Ask and answer questions about key details in a text read aloud or information presented orally or through other media.

Alberta - Grade 2 - ICT

Grade 2

ICT

C5: Students will use technology to aid collaboration during inquiry.

C6: Students will use technology to investigate and/or solve problems.

F6: Students will demonstrate a basic understanding of the operating skills required in a variety of technologies.

Ontario - Grade 2 - Mathematics

Grade 2

Mathematics: Algebra (Coding)

C3.1 solve problems and create computational representations of mathematical situations by writing and executing code, including code that involves sequential and concurrent events

Nova Scotia - Grade 2 - ICT

Grade 2

ICT

Outcome 5: Students will be expected to select and use, with teacher support, grade-appropriate digital tools to develop and represent learning for various purposes, both individually and collaboratively. 

Outcome 9: Students will be expected to 

  • use grade-appropriate ICT terminology

  • follow verbal instructions and visual reminders to safely operate computers and digital devices

British Columbia - Grade 2 - ADST

Grade 2

ADST 

• Use trial and error to make changes, solve problems, or incorporate new ideas from self or others 

• Develop their skills and add new ones through play and collaborative work