# Zombie Tag Game with Circuit Playground Express

## Overview

![](https://cdn-learn.adafruit.com/assets/assets/000/058/367/medium800/circuitpython_banner_nosig.jpg?1532990373)

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.&nbsp;

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&nbsp; a Circuit Playground Express, portable power pack and a way to attach the CPX to the front of a players shirt

Featured
### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

## Portable Power
Featured
### 3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip

[3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip](https://www.adafruit.com/product/3286)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries, plus it has&nbsp;a nifty&nbsp;on-off...

In Stock
[Buy Now](https://www.adafruit.com/product/3286)
[Related Guides to the Product](https://learn.adafruit.com/products/3286/guides)
![Angled shot of 3 x AAA battery holder with on-off switch, JST PH connector, and belt clip.](https://cdn-shop.adafruit.com/640x480/3286-00.jpg)

OR

Featured
### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)
![Front angled shot of 3 x AAA battery holder with on-off switch and 2-pin JST PH connector.](https://cdn-shop.adafruit.com/640x480/727-07.jpg)

## Circuit Playground Attachment
Featured
### Silver Pin Back with Foam Adhesive

[Silver Pin Back with Foam Adhesive](https://www.adafruit.com/product/2838)
This little **Silver-color Pin with Foam Adhesive** is the perfect way to attach any PCB or small component to cloth material.&nbsp;

The adhesive forms a solid but not permanent bond for a strong reliable hold. The pin also has a handy little locking mechanism to keep the...

In Stock
[Buy Now](https://www.adafruit.com/product/2838)
[Related Guides to the Product](https://learn.adafruit.com/products/2838/guides)
![Angled shot of silver pin with foam adhesive.](https://cdn-shop.adafruit.com/640x480/2838-03.jpg)

OR

Featured
### Magnetic Pin Back

[Magnetic Pin Back](https://www.adafruit.com/product/1170)
These magnetic pin backs have two pieces: a metal bar with adhesive strip and a plastic piece with two strong rare-earth magnets. Affix the metal bar to your FLORA projects-- it's just the right size! Then attach your FLORA project to any garment without poking holes in your clothes. The...

In Stock
[Buy Now](https://www.adafruit.com/product/1170)
[Related Guides to the Product](https://learn.adafruit.com/products/1170/guides)
![a metal bar with adhesive strip and a plastic piece.](https://cdn-shop.adafruit.com/640x480/1170-04.jpg)

OR use some safety pins!

# Zombie Tag Game with Circuit Playground Express

## Zombie Game Time!

![](https://cdn-learn.adafruit.com/assets/assets/000/058/369/medium800/circuitpython_banner.jpg?1532991300)

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
 **HUMAN** - Try not to lose all of your health points.

![circuitpython_humans.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/364/medium640/circuitpython_humans.jpg?1532990222)

 **ZOMBIE** - Slowly reduces human health by 1 point.

&nbsp;

**Goal:** Turn all humans into Zombies

![circuitpython_zombie.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/365/medium640/circuitpython_zombie.jpg?1532990238)

 **HEALER** - Quickly restores human health by 1 point.

&nbsp;

**Goal:** Find humans that are low on health and heal them up!

![circuitpython_healer.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/366/medium640/circuitpython_healer.jpg?1532990257)

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.

# Zombie Tag Game with Circuit Playground Express

## 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.

[Welcome to CircuitPython](https://learn.adafruit.com/welcome-to-circuitpython/)
[CircuitPython Essentials](https://learn.adafruit.com/circuitpython-essentials/)
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&nbsp; &nbsp; &nbsp; CircuitPython.&nbsp;[You can learn about Mu and installation in this tutorial](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor "Mu tutorial").

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:

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/Circuit_Playground_Express_IR_Zombie_Game/code.py

## 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 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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/129/medium800thumb/circuitpython_CPXHumanZombie.jpg?1532640131)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/130/medium800thumb/circuitpython_CPXHealerHuman.jpg?1532640310)

## 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!

# Zombie Tag Game with Circuit Playground Express

## MakeCode Zombies

If you haven't used MakeCode before, then check out the following guide:

[MakeCode for Circuit Playground Express](https://learn.adafruit.com/makecode/)
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:

[Load the MakeCode for the CPX Zombie](https://makecode.adafruit.com/75559-41483-93074-87871)
![](https://cdn-learn.adafruit.com/assets/assets/000/058/371/medium800/circuitpython_zombie_full.jpg?1532993447)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/372/medium800/circuitpython_zombie_onstart.jpg?1532993466)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/375/medium800/circuitpython_zombie_forever1.jpg?1532993496)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/376/medium800/circuitpython_zombie_forever2.jpg?1532993506)

And that's it. Now let's look at the Healer.

# Healer

Here's the link to the Healer MakeCode:

[Load the MakeCode for the CPX Healer](https://makecode.adafruit.com/10004-62746-07208-62068)
![](https://cdn-learn.adafruit.com/assets/assets/000/058/377/medium800/circuitpython_healer_full.jpg?1532993539)

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:

[Load the MakeCode for the  CPX Human](https://makecode.adafruit.com/95585-46048-15523-33858)
![](https://cdn-learn.adafruit.com/assets/assets/000/058/380/medium800/circuitpython_human_full.jpg?1532993609)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/381/medium800/circuitpython_human_onstart.jpg?1532993621)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/382/medium800/circuitpython_human_onir.jpg?1532993633)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/383/medium800/circuitpython_human_forever1.jpg?1532993641)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/384/medium800/circuitpython_human_forever2.jpg?1532993672)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/385/medium800/circuitpython_human_forever3.jpg?1532993682)

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......._

# Zombie Tag Game with Circuit Playground Express

## 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.

Featured
### 3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip

[3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip](https://www.adafruit.com/product/3286)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries, plus it has&nbsp;a nifty&nbsp;on-off...

In Stock
[Buy Now](https://www.adafruit.com/product/3286)
[Related Guides to the Product](https://learn.adafruit.com/products/3286/guides)
![Angled shot of 3 x AAA battery holder with on-off switch, JST PH connector, and belt clip.](https://cdn-shop.adafruit.com/640x480/3286-00.jpg)

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.

Featured
### Silver Pin Back with Foam Adhesive

[Silver Pin Back with Foam Adhesive](https://www.adafruit.com/product/2838)
This little **Silver-color Pin with Foam Adhesive** is the perfect way to attach any PCB or small component to cloth material.&nbsp;

The adhesive forms a solid but not permanent bond for a strong reliable hold. The pin also has a handy little locking mechanism to keep the...

In Stock
[Buy Now](https://www.adafruit.com/product/2838)
[Related Guides to the Product](https://learn.adafruit.com/products/2838/guides)
![Angled shot of silver pin with foam adhesive.](https://cdn-shop.adafruit.com/640x480/2838-03.jpg)

Attaching it to the board is pretty easy.

Remove the backing and stick the pin to the back of the Circuit Playground Express.

![circuitpython_stick_pin1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/454/medium640/circuitpython_stick_pin1.jpg?1533062902)

Ready for action!

(but be careful of the sharp pointy pin)

![circuitpython_stick_pin2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/455/medium640/circuitpython_stick_pin2.jpg?1533062948)

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.

Featured
### Magnetic Pin Back

[Magnetic Pin Back](https://www.adafruit.com/product/1170)
These magnetic pin backs have two pieces: a metal bar with adhesive strip and a plastic piece with two strong rare-earth magnets. Affix the metal bar to your FLORA projects-- it's just the right size! Then attach your FLORA project to any garment without poking holes in your clothes. The...

In Stock
[Buy Now](https://www.adafruit.com/product/1170)
[Related Guides to the Product](https://learn.adafruit.com/products/1170/guides)
![a metal bar with adhesive strip and a plastic piece.](https://cdn-shop.adafruit.com/640x480/1170-04.jpg)

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.

![circuitpython_mag_pin1.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/456/medium640/circuitpython_mag_pin1.jpg?1533063006)

Ready for action!

![circuitpython_mag_pin2.jpg](https://cdn-learn.adafruit.com/assets/assets/000/058/457/medium640/circuitpython_mag_pin2.jpg?1533063058)

Pockets also make for convenient battery storage if you can't find a place to clip the battery pack.

![](https://cdn-learn.adafruit.com/assets/assets/000/058/458/medium800/circuitpython_human_shirt.jpg?1533063137)

_ **OH NO! Losing health! Need to find a Healer fast!** _


## Guide Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### 3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip

[3 x AAA Battery Holder with On/Off Switch, JST, and Belt Clip](https://www.adafruit.com/product/3286)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries, plus it has&nbsp;a nifty&nbsp;on-off...

In Stock
[Buy Now](https://www.adafruit.com/product/3286)
[Related Guides to the Product](https://learn.adafruit.com/products/3286/guides)
### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)
### Silver Pin Back with Foam Adhesive

[Silver Pin Back with Foam Adhesive](https://www.adafruit.com/product/2838)
This little **Silver-color Pin with Foam Adhesive** is the perfect way to attach any PCB or small component to cloth material.&nbsp;

The adhesive forms a solid but not permanent bond for a strong reliable hold. The pin also has a handy little locking mechanism to keep the...

In Stock
[Buy Now](https://www.adafruit.com/product/2838)
[Related Guides to the Product](https://learn.adafruit.com/products/2838/guides)
### Magnetic Pin Back

[Magnetic Pin Back](https://www.adafruit.com/product/1170)
These magnetic pin backs have two pieces: a metal bar with adhesive strip and a plastic piece with two strong rare-earth magnets. Affix the metal bar to your FLORA projects-- it's just the right size! Then attach your FLORA project to any garment without poking holes in your clothes. The...

In Stock
[Buy Now](https://www.adafruit.com/product/1170)
[Related Guides to the Product](https://learn.adafruit.com/products/1170/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [FruitBox Sequencer: Musically Delicious Step Pattern Generator ](https://learn.adafruit.com/circuitpython-fruitbox-sequencer-musically-delicious-step-pattern-generator.md)
- [Unicorn Christmas Stocking with Rainbow Lights & Sound](https://learn.adafruit.com/unicorn-christmas-stocking-with-lights-sound.md)
- [Make It Pulse](https://learn.adafruit.com/make-it-pulse.md)
- [MIDI Stomping Pads](https://learn.adafruit.com/midi-stomping-pads.md)
- [Circuit Playground Express Head-Tilt Ears](https://learn.adafruit.com/circuit-playground-express-head-tilt-ears.md)
- [Make It Sound](https://learn.adafruit.com/make-it-sound.md)
- [Make It Plot](https://learn.adafruit.com/make-it-graph-plot.md)
- [Hammer Time Mini Golf Hazard with Crickit](https://learn.adafruit.com/mini-golf-hammer-time-circuit-playground-crickit.md)
- [Make It a Keyboard](https://learn.adafruit.com/make-it-a-keyboard.md)
- [Crickit Paddle Wheel Boat](https://learn.adafruit.com/crickit-boat.md)
- [Icicle Crown with Pebble Pixels & WLED](https://learn.adafruit.com/icicle-crown-with-pebble-pixels-wled.md)
- [Qu'est-ce que MakeCode?](https://learn.adafruit.com/makecode-fr.md)
- [Xenomorph Halloween Candy Bucket](https://learn.adafruit.com/xenomorph-halloween-candy-bucket.md)
- [Crawling Baby Sea Turtle Robot](https://learn.adafruit.com/baby-turtle-makecode.md)
- [Meeting Time Keeper Stick](https://learn.adafruit.com/meeting-time-keeper-stick-with-cpx.md)
