GRADE 7 · COMPUTING · UNIT 2 · LESSON 2.12

Decomposing problems: Creating a smart solution

Testing accelerometer gestures

Read a little. Try the workbook. Check your answers. Choose one section below to get started.

7 fillable worksheet pagesRead at your own pace

LET’S TRACE, REASON AND TEST

Testing accelerometer gestures

Book extension, project or review · original companion practice

The accelerometer can recognise specified movements or orientations. Use the exact gesture name accepted by the selected API, decide what output follows detection and test the no-gesture case too. Handle equipment gently; no learner needs to drop a device to complete the paper activities.

Today’s two goals
  • Describe how an accelerometer detects a gesture used as a program input.
  • Edit a gesture condition and test the corresponding display output.
Original PaxaKids illustration for Testing accelerometer gestures. Precise program text and data are supplied in the workbook models.
An original PaxaKids workbook scene. Use the supplied programs and data for precise workbook facts.

Explore the clues

Tap one card to find out more.

Understand the idea

The accelerometer can recognise specified movements or orientations. Use the exact gesture name accepted by the selected API, decide what output follows detection and test the no-gesture case too. Handle equipment gently; no learner needs to drop a device to complete the paper activities.

Concept to practise: Testing accelerometer gestures.

Work through an example

A shake-detection condition can show a tick when a matching event has been recorded. That does not prove every movement is a shake, nor that a simulator verifies the real sensor. The actual API and test method matter.

Try before your workbook

What two kinds of test would you plan for a shake alert, and how should you label a worksheet-only trace?

Check my readiness thinking

Plan a recognised-shake case and a no-matching-gesture case. Label worksheet reasoning as a paper trace or prediction. Claim a physical sensor result only after a real, appropriately supervised device test.

Your original programs and learning models

These original PaxaKids program and data models support your workbook. Some examples deliberately contain faults to investigate. Follow their headings and preserve exact code case, punctuation and order. Traces and supplied records are not claims of physical testing.

Use movement as a program input

Our goal: edit and test a gesture condition, observe its tick output and explain what action triggered it.

An accelerometer measures acceleration. Its software can recognise movement and orientation patterns as named gestures. The gesture name is a string; a call asking whether that gesture occurred returns True or False.

Read the original gesture tester

ORIGINAL MICROPYTHON GESTURE TESTER
from microbit import *
GESTURE = "shake"
display.clear()

while True:
    if accelerometer.was_gesture(GESTURE):
        display.show(Image.YES)
        sleep(400)
        display.clear()
    sleep(20)

Use exact supported gesture strings

Use exact supported gesture strings — original model
Example assignmentExample assignment
GESTURE = "shake"GESTURE = "up"
GESTURE = "down"GESTURE = "left"
GESTURE = "right"GESTURE = "face up"
GESTURE = "face down"GESTURE = "freefall"

Follow the detection-and-display loop

    Decision: Gesture detected?

    True branch
    1. Show YES tick
    2. Pause 400 ms
    3. Clear display
    False branch
    1. No new output
    Paxa the Fox

    Try one step with Paxa!

    Use the API for the chosen editor. Label paper traces, simulator runs and physical tests accurately; ask a grown-up before connecting equipment. Save personal responses before leaving.

    Our Unit 2 learning path
    1. Lesson 2.1: All about software
    2. Lesson 2.2: Introducing the micro:bit
    3. Lesson 2.3: Using Python with the micro:bit
    4. Lesson 2.4: The micro:bit Python environment
    5. Lesson 2.5: Correcting errors using a flowchart
    6. Lesson 2.6: Using sensors in programming
    7. Lesson 2.7: Flowcharts for algorithm planning
    8. Lesson 2.8: Algorithmic solutions and data types
    9. Lesson 2.9: Planning a smart solution
    10. Lesson 2.10: Effective testing
    11. Lesson 2.11: Evaluating a program
    12. Lesson 2.12: Testing accelerometer gestures
    13. Lesson 2.13: Protecting a museum crown
    14. Lesson 2.14: Final project
    15. Lesson 2.15: Evaluation
    16. Lesson 2.16: What can you do?
    For grown-ups: using this lesson

    Your answers are checked in your browser. Open responses need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.

    Read one explanation, discuss the model and try the readiness check before the workbook. Choose “Mark lesson finished” when ready. Optional account progress saves lesson position and completion across devices; save personal responses before leaving.

    2. Fill in your workbook

    Read the teaching and the complete workbook instructions. Choose, write or draw; Answer list offers larger controls. Trace code precisely and distinguish predictions from actual tests. Review designs, explanations and drawings with a grown-up.

    Testing accelerometer gestures7 student pages · original artwork

    Opening your PDF…

    Swipe sideways across the worksheet on a small screen, or use “Answer list” for larger controls.

    TAKE YOUR PRACTICE OFFLINE

    3. Download the student worksheet

    All 7 original A4 student pages, ready for pencil-and-paper practice. Choose Review Answers to check your work on this webpage.

    Student worksheet only · PDF · 8.3 MiB · No answer key included

    Download worksheet PDF ↓

    TRY FIRST, THEN CHECK TOGETHER

    Download the student worksheet →

    4. Answers & guidance

    Finished your try? Open the guide and compare one worksheet at a time. Your own words may be different and still explain the right idea.

    Shown on this webpage only. There is no answer-key download, and this guide is left out when printing the page.

    Show answers for all 7 worksheets

    Worksheet 1

    1. Question 1: Which component supplies movement information? the accelerometer
    2. Question 2: What does was_gesture return for the named gesture test? a Boolean

    Worksheet 2

    1. Question 3: Which line selects the shake gesture? GESTURE = "shake"

    Worksheet 3

    1. Question 4: Which string correctly names the face-up gesture? "face up"
    2. Question 5: Which statement about changing the selected name is accurate? save/send the new revision, then test its action

    Worksheet 4

    This page introduces the activity. There are no marked responses on this sheet.

    Worksheet 5

    1. Question 6: The selected gesture test returns True. What happens? show a tick, pause, clear it, then continue checking
    2. Question 7: The selected gesture test returns False. What does the if block do? it is skipped; no new display output is issued
    3. Question 8: Why record the board action as well as the selected string? to explain which observed action triggered the output

    Worksheet 6

    1. Question 9: For each listed gesture, edit GESTURE, save/send the revision and test it. Describe the action or orientation used and the observed output. Identify any unperformed test as pending; use a supported simulator or teacher-led demonstration for freefall rather than dropping the board. Eight source-listed gesture names retained. Record exact selected string, revision/transfer, actual action/orientation and observed tick/clear behaviour. Up/down/left/right should describe the orientation that actually triggered the device, not a guessed screen direction. face up/down relate to LED-face orientation; shake is deliberate shaking. Freefall should be supported simulator/teacher-led protected demonstration, never dropping the device; pending acceptable if unavailable. Distinguish actual board, simulator and untested predictions. No fabricated pass or numeric scoring. Optional detailed CSV records partner discussion and retests. Grown-up review; personal evidence is required.

    Worksheet 7

    1. Question 10: Name the gesture, source revision and test method. Explain the selected string, Boolean condition and tick/clear sequence. Describe the action that triggered it, a trial that did not trigger it and any repair/retest. Explain the purpose of the repeated loop and the two pauses, then record your partner’s explanation or feedback. Exact supported gesture string, saved/sent revision and honest method. was_gesture(GESTURE) checks the named gesture occurrence and returns Boolean; it is not a numeric acceleration or a displayed string. True shows Image.YES, sleep(400), clear; common sleep(20) and repeat. False skips output block. Record actual positive/negative trials with corresponding actions and outputs, repair/retest as needed; no-device pending. Pauses give visible tick and a short polling delay; the program does not check gestures continuously during the 400 ms wait. Recognising gestures still requires repeated accelerometer calls. Partner discussion/feedback or honestly labelled self-explanation. C07 applied: chosen predicate returns Boolean. No numeric scoring. Grown-up review; personal evidence is required.
    Back to my workbook ↑

    Curriculum & workbook reference

    Computing for your homeschool day

    Explore Testing accelerometer gestures with this free Grade 7 Computing lesson. Read one idea together, try the fillable workbook and return to review at your own pace. Download the same student worksheet PDF for pencil-and-paper practice.

    Fit learning around your family’s day. There is no timer and no sign-up is needed to use the lesson. An optional account saves your lesson position and completion across devices. Workbook responses and drawings stay in this tab; save a copy of your responses before leaving.

    Understand your results

    Your answers are checked in your browser. Open responses need grown-up review and are shown separately from the automatic score. Check your work, then use “Retry answers to practise” to revisit mistakes while keeping correct responses.

    Choose Review Answers after trying the activity. The guide stays on the webpage; the worksheet download contains only the student pages.

    For programme background, visit the Cambridge Lower Secondary Computing overview. PaxaKids provides independent original companion practice.

    The book pages identify the related teaching topic. The explanations, characters, programs and exercises here are original PaxaKids companion practice. Practical tasks require the appropriate editor and, where applicable, suitable equipment. A design or paper trace is not a verified hardware result. Only completed, reviewed lessons are listed.

    Explore the Cambridge Lower Secondary Computing curriculum for programme background. PaxaKids is an independent learning resource.