Skip to Main Content
Save the World with Code: 20 Fun Projects for All Ages Using Raspberry Pi, micro:bit, and Circuit Playground Express
book

Save the World with Code: 20 Fun Projects for All Ages Using Raspberry Pi, micro:bit, and Circuit Playground Express

by Lorraine Underwood
April 2020
Intermediate to advanced content levelIntermediate to advanced
224 pages
6h 2m
English
McGraw-Hill Education TAB
Content preview from Save the World with Code: 20 Fun Projects for All Ages Using Raspberry Pi, micro:bit, and Circuit Playground Express

MISSION 9

A Lock to Protect Your Sword

We want to keep our sword from Mission 5 safe. Unlike the door in your room, the sword can be anywhere at any time. We want to put a lock on the sword, and if anyone tries to move the sword, an alarm will go off, and the sword won’t work. This alarm can go on anything that you want to keep safe, not just the sword.

You don’t need a speaker for this mission, because the lock will stop the sword from working. We’re going to use if and else statements.

ELSE

We briefly saw an else back in the Debug section of Circuit Playground Express in Mission 3. It covers everything the if doesn't. Remember the algorithm:

What do we do if Lorraine is not hungry? That’s where else comes along.

Only one of these actions ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Science and Engineering Projects Using the Arduino and Raspberry Pi: Explore STEM Concepts with Microcomputers

Science and Engineering Projects Using the Arduino and Raspberry Pi: Explore STEM Concepts with Microcomputers

Paul Bradt, David Bradt
Card Games by Thiagi: A User's Guide

Card Games by Thiagi: A User's Guide

Sivasailam Thiagi Thiagarajan

Publisher Resources

ISBN: 9781260457605