Zombie Tag Game with Circuit Playground Express

Similar documents
Meditation Trainer. Created by Collin Cunningham. Last updated on :36:45 PM UTC

Laser Tag Pro: Battle Rifle

Square Wave TIG 200 TIG WELDING MACHINE

A Beginner s Guide to Portable Electric Fencing A summary of an interview with Stephanie Sexton, Product Manager at Premier 1 Supplies

Documentation. By Henry Arnold

Owner's Handbook CX-Series MP Control Console for Line-Score with Pitch Speed Software Version 4.0.2

LEGO Engineering Conferences ROBOLAB and MINDSTORMS Education Version 4.5 March 2008

OPERATING INSTRUCTIONS FOR

Section Freepoint Service 26.1 FREEPOINT CONTROL PANEL

outdoor CoCkpit

MP-70/50 Series Scoreboard Controller User Guide

A4s Operation Manual

Microsoft Windows Software Manual for FITstep Stream Version 4

Operating Instructions

Wickets Administrator

OPERATING INSTRUCTIONS FOR MODEL VSBX

GEN II Robot Soccer EV3 Compass Training Curriculum Brian Thomas

A4 Operation Manual. Fig.1-1 Controller Socket Diagram

PHUD12 HEAD UP DISPLAY User Manual

REGNLY TIME RECORDER RTR 2 USERS MANUAL CONTENTS

WEEK #1 44 MILES MONDAY, JULY 15, 2014 DAY OFF

Standard League WRO Football Simple Simon EV3 Training Curriculum

User Manual GRI- 1500Li

Dimensions [All numbers in brackets are in millimeters.] K4-2 US (supplied) 1/2" Centered (Default)

Scoreboard Operator s Instructions MPC Control

ADVANCED PORTABLE LAUNCH MONITOR. ES14 User Manual

EZ Boom 2010 System for the EZ Guide 500 Lightbar Triangle Ag Services Users Guide

Reflow Oven HHL3000 INSTRUCTION MANUAL POHUA - jedyny autoryzowany przedstawiciel w Polsce

YSC-8330 USER MANUAL XI AN TYPICAL INDUSTRIES CO.,LTD.

OPERATING INSTRUCTIONS FOR

STX 165 Operation. Data Knob Enter Pushbutton. Power/Mode Control. Select Knob Ident Pushbutton. VFR Pushbutton

Standard League Robot Soccer EV3 Compass Training Curriculum Brian Thomas

Technology. In the My Files [My Files] submenu you can store all the programs that you have made on the NXT or downloaded from your computer.

WIND CLIPPER KTS ILLUM SCALE INC DEC CLIPPER WIND SYSTEM

Step 1. CoderDojo Milltown Exercise 1 Pong Page 1 of 13

then extrapolated to larger area just based on the length of bank [that actually falls in this category].

User Manual. Heads-Up Display (HUD) DiveCAN. Mechanical Button Version

PTG100 Precision Test Gauge

DRILL MONITOR DM-100 OPERATIONS MANUAL

Datasheet: K-30 ASCII Sensor

( ) ( ) *( A ) APPLICATION DATA. Procidia Control Solutions Coarse/Fine Control. Split-Range Control. AD Rev 2 April 2012

X-Series User Guide Rev. E

Roller AC Servo System

OPERATOR S MANUAL Ar-Gone Weld Gas Analyzer

DESIGNED AND MANUFACTURED IN ENGLAND CLIPPER DEPTH DEPTH METRES ECHO SOUNDER.

Push Button Minute Timer Programmable between 1 minute and 30 minutes with built in multi-way control

INSTRUCTION MANUAL D Pedometer with Clip. VIDEO INSTRUCTIONS:

survey/doa5lr/

WELCOME TO THE REVOLUTION

ACCUSTRIDE ACCUSTRIDEFM. Digital Clip-on Pedometer WC153. Digital Clip-on Pedometer WC154 ENGLISH

THE SOUNDBEAM 2 HANDBOOK PART 2 STEP BY STEP

Walk-O-Meter User Manual

Simple Simon GEN II Robot Soccer EV3 -Tris 10 Training Curriculum

!!!! finished video as an example. See Video Examples for more information about the camera I used.

Terratrip 303 Plus: Codriver s Guide

User s Manual. Copyright 2014 Trick Technologies Oy

FAULT CODE TROUBLESHOOTING INDEX

MP-70/50 Series Scoreboard Controller User Guide

UBEC 1AT. AUTO TANK Fill System Installation, Operation, & Setup Instructions

CONSOLE-320 ENGLISH. 230A: CONSOLE-320 with cable data output Item 230B: CONSOLE-320 with cable + wireless radio data output

OWNER S MANUAL. All PowaKaddy electric trolleys have been awarded the Quiet Mark by the Noise Abatement Society

Lesson: Pitch Trim. Materials / Equipment Publications o Flight Training Manual for Gliders (Holtz) Lesson 4.4 Using the Trim Control.

Standard Operating Procedure. For. PVD E-Beam

陕西创威科技有限公司. Shaanxi Creat Wit Technology Co., Ltd. Precision pressure calibrator-cwy300 Operating Manual

uemis CONNECT: Synchronisation of the SDA with myuemis

WATER CONTROL SYSTEM QUICK START

Tutorial: Adding Twitch ChatPlay

Operation and Maintenance Manual for the Dive Control Helium Speech Unscrambler

unconventional-airsoft.com

Shearwater GF Computer

SENSAPHONE APPLICATION NOTE. Functions: C Programming, Pump Control, Data Logging

In Response to a Planned Power Outage: PPMS EverCool II Shut Down and Re-start Procedure

Manual Weighingblock VB2 series and Uniscale

10 Essential Tips on Clearing a House

Calibration Gas Instrument INSTRUCTION MANUAL. Release I. Advanced Calibration Designs, Inc.

BSP Pressure Sensor Balluff GmbH, BA Marco Zorcic.

LED CONVERSION BOARD - YAKUZA SERIES EGO/GEO

Exercise 8. Closed-Loop Pressure Control, Proportional-Plus-Integral Mode EXERCISE OBJECTIVE

SAPCON. User Manual. Capacitance Continuous Level Indicator. . Introduction. . General Description. . Principle of Operation. .

nvisti Kestrel Companion Pro For Android

To Logon On to your tee sheet, start by opening your browser. (NOTE: Internet Explorer V. 6.0 or greater is required.)

OMNISPORT 2000 SWIMMING QUICK REFERENCE

User Manual GRX- 1250Li

Joey Mob Program Planner

Blossoms_-_How_Big_is_a_Mole_v4

Digital Level Control One and Two Loops Proportional and Integral Control Single-Loop and Cascade Control

Get it here. Page 1 of 7 Date:Jan 8, 2014

iregatta User Manual

The NXT Generation. A complete learning solution

TANK MANAGER FOR TWO TANKS OPERATING MANUAL. 10/31/11 C-More T6C L color touch panel

Slide 1 - Welcome to an Overview of the Student Center and New Titan Online

Version-E Manual

Thinking of the Serve as a Weapon

CONTROL and INSTRUMENTATION

GRUNDFOS DATA BOOKLET. Hydro Solo-E. Complete pressure boosting systems 50/60 Hz

Press Conference Barry Melrose June 24, 2008

IBU3 Manual Addendum 1

PARTS IDENTIFIER HARDWARE

GRI-1300/1350Li. User Manual

ECL Comfort 110, application 131 (valid as of software version 2.00)

Transcription:

Zombie Tag Game with Circuit Playground Express Created by Kattni Rembor Last updated on 2018-08-22 04:10:48 PM UTC

Guide Contents Guide Contents Overview Parts List Circuit Playground Express Portable Power 3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST Circuit Playground Attachment Silver Pin Back with Foam Adhesive Magnetic Pin Back Zombie Game Time! The Characters CircuitPython Zombies Healer Zombie Human Time To Play! MakeCode Zombies Zombie Healer Human Make It Wearable 3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip Silver Pin Back with Foam Adhesive Magnetic Pin Back 2 3 3 3 4 4 4 4 4 5 6 6 9 11 11 12 13 14 14 15 16 20 20 20 22 Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 2 of 23

Overview You're a human! Right? For now anyway... There's a red pulsing in the distance... OH NO! IT'S A ZOMBIE! You're losing health, but what's this? A white pulsing from around a corner, a healer! You'll stay human for a little longer... Hopefully long enough to check out this guide! Using Circuit Playground Express you can make a game that's half laser-tag half hide-and-seek. This game requires at least three players, which means it requires at least three Circuit Playground Expresses. You can play with as many more than three, as many as you want! It's great for workshops, classrooms, camps or other groups of 3 or more! The more people you have, the more fun the game gets. This guide will go through the code for the game, explain how it works and how to play. Good luck and have fun! Parts List For EACH player, you'll need a Circuit Playground Express, portable power pack and a way to attach the CPX to the front of a players shirt Your browser does not support the video tag. Circuit Playground Express $24.95 IN STOCK ADD TO CART Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 3 of 23

Portable Power 3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip $2.95 IN STOCK ADD TO CART OR 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST $1.95 IN STOCK ADD TO CART Circuit Playground Attachment Silver Pin Back with Foam Adhesive $0.45 IN STOCK ADD TO CART OR Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 4 of 23

Magnetic Pin Back $1.95 IN STOCK ADD TO CART OR use some safety pins! Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 5 of 23

Zombie Game Time! We've written up a fun game of zombie tag for you to use with Circuit Playground Express (CPX). It uses infrared signals to communicate between CPXs. You can be human, a zombie or a healer. The human is affected by zombies and healers. If a human comes into contact with a zombie, they start to lose health points. That's where the healer comes in. If a human comes into contact with a healer, they regain health points. The goal is to maintain at least one health point. If a human loses all health, they become a zombie too! And zombies can't return to being humans. But, they can start attacking other humans! So, run when you see them! The game starts with at least one healer, at least one zombie, and the rest of the players are humans. If you have a large group, try having 2 or 3 zombies. This game works great in a large room or outdoors, as long as people can run around and hide. The Characters Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 6 of 23

HUMAN - Try not to lose all of your health points. ZOMBIE - Slowly reduces human health by 1 point. Goal: Turn all humans into Zombies Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 7 of 23

HEALER - Quickly restores human health by 1 point. Goal: Find humans that are low on health and heal them up! Each board lights up a different color to identify the role. Humans are solid green, healers slowly pulse white, and zombies quickly pulse red. The healer and zombie boards emit different IR signals. The human board waits to receive these signals. When a zombie signal is received, the human loses one health point. When a healer signal is received, the human regains one health point. The current number of health points for the human are shown by the NeoPixels lit up. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 8 of 23

CircuitPython Zombies If you are new to CircuitPython, be sure to check out the Welcome guide for an overview. And if you want to know even more, check out the Essentials guide. https://adafru.it/alp https://adafru.it/alp https://adafru.it/bx8 https://adafru.it/bx8 Ensure your Circuit Playground Express has CircuitPython 3.0 or later. Adafruit suggests using the Mu editor to edit your code and have an interactive REPL in about Mu and installation in this tutorial (https://adafru.it/ano). CircuitPython. You can learn In the CircuitPython version, you can select what you want to be when the board is powered up. To be a human, simply start up the board. To be a healer, hold down button A while first running the program. To be a zombie, hold down button B while first running the program. Copy the following to code.py on at least three Circuit Playground Expresses: import time import pulseio import board import adafruit_irremote import digitalio import neopixel pixels = neopixel.neopixel(board.neopixel, 10) button_a = digitalio.digitalinout(board.button_a) button_a.switch_to_input(pull=digitalio.pull.down) button_b = digitalio.digitalinout(board.button_b) button_b.switch_to_input(pull=digitalio.pull.down) red_led = digitalio.digitalinout(board.d13) red_led.direction = digitalio.direction.output # Create a 'pulseio' input, to listen to infrared signals on the IR receiver pulsein = pulseio.pulsein(board.ir_rx, maxlen=120, idle_state=true) # Create a decoder that will take pulses and turn them into numbers decoder = adafruit_irremote.genericdecode() # Create a 'pulseio' output, to send infrared signals on the IR transmitter @ 38KHz pwm = pulseio.pwmout(board.ir_tx, frequency=38000, duty_cycle=2 ** 15) pulseout = pulseio.pulseout(pwm) # Create an encoder that will take numbers and turn them into NEC IR pulses encoder = adafruit_irremote.generictransmit(header=[9500, 4500], one=[550, 550], zero=[550, 1700], trail=0) # Set between 0 and 1 to set LED pulse speed. Smaller numbers are slower. healer_led_pulse = 0.008 Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 9 of 23

zombie_led_pulse = 0.07 pixels.brightness = 0.0 # Change to set number of seconds between each signal being sent. HEALER_TIME = 1 ZOMBIE_TIME = 3 # The Healer and Zombie IR signal codes HEALER_IR = [72, 69, 65, 76] ZOMBIE_IR = [90, 79, 77, 66] human_health_counter = 10 human = 0 healer = 1 zombie = 2 if button_a.value: # Hold button A down before starting up to set mode Healer. mode = healer pixels.fill((255, 255, 255)) pixels.brightness = 0.3 elif button_b.value: # Hold button A down before starting up to set mode Zombie. mode = zombie pixels.fill((255, 0, 0)) pixels.brightness = 0.8 else: # Defaults to human mode! mode = human pixels.fill((0, 255, 0)) pixels.brightness = 0.5 start = time.monotonic() while True: now = time.monotonic() if mode is human: pulses = decoder.read_pulses(pulsein) try: # Attempt to convert received pulses into numbers received_code = decoder.decode_bits(pulses) except adafruit_irremote.irnecrepeatexception: # We got an unusual short code, probably a 'repeat' signal continue except adafruit_irremote.irdecodeexception: # Something got distorted or maybe its not an NEC-type remote? continue print("nec Infrared code received: ", received_code) if received_code == ZOMBIE_IR: print("zombie code received!") pixels.fill(0) human_health_counter -= 1 for i in range(human_health_counter): pixels[i] = (0, 255, 0) if human_health_counter < 1: mode = zombie pixels.fill((255, 0, 0)) print("zombified!") if received_code == HEALER_IR: print("healer code received!") if human_health_counter < 10: pixels.fill(0) human_health_counter += 1 for i in range(human_health_counter): Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 10 of 23

for i in range(human_health_counter): pixels[i] = (0, 255, 0) else: pass elif mode is zombie: brightness = pixels.brightness brightness += zombie_led_pulse if not 0.0 <= brightness <= 1.0: zombie_led_pulse = -zombie_led_pulse continue pixels.brightness = brightness if now - start > ZOMBIE_TIME: print("zombie code sent! \n") red_led.value = True encoder.transmit(pulseout, ZOMBIE_IR) red_led.value = False start = time.monotonic() elif mode is healer: brightness = pixels.brightness brightness += healer_led_pulse if not 0.0 <= brightness <= 0.5: healer_led_pulse = -healer_led_pulse continue pixels.brightness = brightness if now - start > HEALER_TIME: print("healer code sent! \n") red_led.value = True encoder.transmit(pulseout, HEALER_IR) red_led.value = False start = time.monotonic() Healer Let's start with the healer. To choose the healer role, you'll hold down button A while the program starts up. This means you can hold button A before you provide power to the board and let it start up while holding the button. You can also hold the button and then reset the board while continuing to hold the button. When the role is successfully chosen, the LEDs will be white. The healer lights up and slowly pulses the LEDs white. Every second, the healer transmits an IR signal. The little red LED lights up to let you know the signal is being sent. The signal interval is configurable in the code - you can change HEALER_TIME = 1 to a different number of seconds. Increase the number to send the signal less often and make the game more difficult. Decrease the number to send the signal more often and make the game easier. That's all there is to the healer. Healers are not affected by humans or zombies. Zombie Next, we'll look at the zombie. To choose the zombie role, you'll hold down button B while the program starts up. This works the same way as choosing the healer role. You can hold the button down and during powering on the board, or you can hold it down and reset the board while continuing to hold it. When the role is successfully chosen, the LEDs will be red. The zombie lights up and quickly pulses the LEDs red. Every three seconds, the zombie transmits an IR signal. The Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 11 of 23

little red LED lights up to let you know the signal is being sent. The signal interval is configurable in the code - you can change ZOMBIE_TIME = 3 to a different number of seconds. As with the healer, increase the number to send the signal less often and decrease it to send it more often. That's all there is to the zombie. Zombies are not affected by humans or healers. Human Finally, we'll look at the human. To choose the human role, all you have to do is start up the board. The code defaults to the human role. When the role is successfully chosen, the LEDs will be green. The human lights up solid green. The human starts with 10 health points, as indicated by 10 green LEDs. Humans are affected by both healers and zombies. The human waits to receive signals from the healer and zombie. When the zombie signal is received, the human will lose a health point, and one green LED will shut off. This will continue every time a zombie signal is received. If the human cannot find a healer, they'll continue to lose health points until they have 0. When this happens, the human will turn into a zombie. Zombies can't return to being human. At that point, they'll start transmitting the zombie signal which can affect any other humans still in the game. When a healer signal is received, the human will regain one health point, and the last green LED will turn back on. As long as the human is receiving the healer signal, they will continue to regain health points, and the green LEDs will turn back on until the human is at full health. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 12 of 23

Time To Play! Now it's time to load the code on as many boards as you can find, start them up into the role you'd like to play, and start running! Good luck! Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 13 of 23

MakeCode Zombies If you haven't used MakeCode before, then check out the following guide: https://adafru.it/agq https://adafru.it/agq For the MakeCode version, there are three separate programs. You choose what you want to be by loading the appropriate version. We'll go over each below, starting with the Zombie and Healer, since they are very similar and the most simple. Zombie Here's the link to the Zombie MakeCode: https://adafru.it/bz7 https://adafru.it/bz7 There are only thee main chunks. The first is the on start block, which just sets the initial values for some variables and turns all the NeoPixels to Zombie Red. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 14 of 23

The Zombie needs to send out the Zombie code every now and then to try and attack the Humans. This is done with a forever loop. Pretty simple - it sends out the code and then sleeps for the amount of time set by ZOMBIE_TIME. Then does it again - over and over, forever. The other forever loop is used to create the pulsing effect on the NeoPixels. This is done by changing the value of brightness up and down over and over again. And that's it. Now let's look at the Healer. Healer Here's the link to the Healer MakeCode: https://adafru.it/bz8 https://adafru.it/bz8 Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 15 of 23

The Healer is pretty much the same thing as the Zombie. It is simply altered to send out a different IR code and at a different rate, have different color NeoPixels, and pulse at a slower rate. Now for those Humans. Human Here's the link to the Human MakeCode: https://adafru.it/bz9 https://adafru.it/bz9 Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 16 of 23

Oof. This one has a lot going on. It doesn't even fit on one screen! But hey, humans are complex. We can still go through it chunk by chunk. It all starts with the familiar on start, which again just initializes a bunch of variables to be used by the program. With the Zombie and Healer, we were transmitting IR signals. For the Human, we need to receive those signals and process them. That is done using the on infrared received block. The value of received_code is checked and the value of health_counter is either decreased or increased, depending on if the code is from a Zombie or a Healer. The value of health_counter is then checked. We limit it to a max of 10. But more importantly, we check to see if it has reached 0. If so, the Human is turned into a Zombie. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 17 of 23

The rest of the code is split amongst several forever loops. The first one checks to see if the CPX is still Human. If so, it updates the NeoPixels to indicate the current amount of health left. The next forever loop kicks in when the CPX becomes a Zombie. It should look similar to the one you saw in the Zombie program. This is what sends out the Zombie code on the IR transmitter. The difference here is we add a check to only do this when the board actually is a Zombie. Therefore, this does not happen when the board is still a Human. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 18 of 23

The last forever loop is what pulses the NeoPixels when the board becomes a Zombie. It is also just the same thing from the Zombie code, but again with a check to only run when the board actually becomes a Zombie. And that's it. It looks like a lot, and it kinda is. Hopefully it helps to try and just think in terms of the large chunks described above. Like the big chunk that "receives the IR signal" and the big chunk that "pulses the NeoPixels". Then it becomes easier to see how these big chunks fit together to make the program work. After that, you can look at the chunks in more detail to try and understand how they are actually achieving that. OK. Enough discussion. Gather up some friends and some Circuit Playground Express boards. Load up the programs. And have fun. rrrrrrrrrrrr...brains... Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 19 of 23

Make It Wearable To be able to run around and play the Zombie Game you'll need some way to battery power the Circuit Playground Express. You'll also want some way to attach the Circuit Playground Express board to the outside of your clothing. For battery power, this 3xAAA battery pack is a good choice. It has an On/Off switch and a nice little belt clip you can use for attaching to clothing. The JST connector plugs right into the Circuit Playground Express. 3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip $2.95 IN STOCK ADD TO CART For actually attaching the Circuit Playground Express, there are various options. This stick pin is one way, but you will need to be careful with the sharp pointy pin. Silver Pin Back with Foam Adhesive $0.45 IN STOCK ADD TO CART Attaching it to the board is pretty easy. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 20 of 23

Remove the backing and stick the pin to the back of the Circuit Playground Express. Ready for action! (but be careful of the sharp pointy pin) Another option is this magnetic holder. It doesn't have any sharp pointy things, but you'll need to be able to put the other side of the holder inside the clothing somehow. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 21 of 23

Magnetic Pin Back $1.95 IN STOCK ADD TO CART Mounting it is similar to the other pin back. Remove the backing and stick the one side of the magnet to the back of the Circuit Playground Express. Ready for action! Pockets also make for convenient battery storage if you can't find a place to clip the battery pack. Adafruit Industries https://learn.adafruit.com/circuit-playground-express-ir-zombie-game Page 22 of 23

OH NO! Losing health! Need to find a Healer fast! Adafruit Industries Last Updated: 2018-08-22 04:10:42 PM UTC Page 23 of 23