Adabot Operation Game

Similar documents
Slider Crank Mechanism -- from Cardboard and Craft Sticks

Infinity Mirror Valentine's Candy Box

Pushrod Garage. Created by John Park. Last updated on :07:30 PM UTC

Ping Pong Ball Launcher

Stumble-Bot. Created by Dano Wall. Last updated on :04:06 AM UTC

Crickit Carnival Bumper Bot

Crickit Powered Holiday Diorama

Crawling Baby Sea Turtle Robot

Circuit Playground Express Laser Tag

Crickit Dancing Marionette Kit Created by Dano Wall. Last updated on :03:11 PM UTC

Snake Charmer Box. Created by Dano Wall. Last updated on :07:25 PM UTC

Hammer Time Mini Golf Hazard with Crickit

Android GBoard Morse Code Control with Circuit Playground Express

The Scream: Interactive Screaming Painting

UFO Flying Saucer with Circuit Playground Express

Bunny Ears with MakeCode

Crawling Animatronic Hand

CPX Mystery Dreidel. Created by Kathy Ceceri. Last updated on :51:40 PM UTC

Con Badge with Circuit Playground Express

Crickit Powered Mini Chair Swing Ride!

Paper Airplane Launcher

Wind Blowing Emoji Prop

CircuitPython Snow Globe

Circuit Playground Express Head-Tilt Ears

PyPortal NeoPixel Color Picker Created by Kattni Rembor. Last updated on :42:41 PM UTC

Mini Golf Course with Circuit Playground and Crickit

Milk Jug Glow Skull. Created by John Park. Last updated on :28:36 PM UTC

Neon LED Signs. Created by John Park. Last updated on :11:09 PM UTC

NeoPixie Dust Bag with Circuit Playground Express

Sword & Wand Prop Effects with Circuit Playground

Trash Panda. Created by Dano Wall. Last updated on :30:46 AM UTC

Easy Sparkle Pocket T-Shirt

Clockwork Goggles. Created by John Park. Last updated on :03:10 PM UTC

Steven Universe Cosplay Shirt & Gem Created by Erin St Blaine. Last updated on :54:25 PM UTC

NeoPixel Fairy Crown. Created by Erin St Blaine. Last updated on :22:47 AM UTC

Adafruit Capacitive Touch Sensor Breakouts

3D Printed Camera LED Ring

LED Eyes. Created by Ruiz Brothers. Last updated on :50:55 AM UTC

Interior Purse Light. Created by Becky Stern. Last updated on :41:08 PM UTC

NeoPixel Bike Light. Created by Ruiz Brothers. Last updated on :43:46 PM UTC

Feather Weather Lamp. Created by Ruiz Brothers. Last updated on :54:26 PM UTC

Trinket NeoPixel LED Longboard

Adafruit LED Sequins. Created by Becky Stern. Last updated on :02:00 AM UTC

Solar Boost Bag. Created by Becky Stern. Last updated on :44:55 PM UTC

Guardian Shield+ Zelda Breath of the Wild

CircuitPlayground Minecraft Gesture Controller

NeoPixel Ring Bangle Bracelet

HalloWing Jump Scare Trap

Overwatch Prop Gun: Lucio's Blaster Pt. 3

No-Sew LED Wristband. Created by Kathy Ceceri. Last updated on :23:40 PM UTC

Portable Apple Watch Charger

3D Printed Google AIY Voice Kit

Circuit Playground Yoyo

Jewel Hair Stick. Created by Leslie Birch. Last updated on :47:17 PM UTC

GPS Logging Dog Harness

Naughty or Nice Machine

'Sup Brows. Created by Kate Hartman. Last updated on :52:04 PM UTC

NeoMatrix 8x8 Word Clock

3D Printed Case for Adafruit Feather

3D Printed 20w Amplifier Box

Light-Up Angler Fish Embroidery

Coffee Detonator: The TNT Plunger Grinder

Audio Prank Gift Box. Created by Becky Stern. Last updated on :46:15 PM UTC

Tent Lantern. Created by Timothy Reese. Last updated on :17:25 AM UTC

Glowing Smokey Skull. Created by Ruiz Brothers. Last updated on :03:40 PM UTC

Boomy The Boombox. Created by Ruiz Brothers. Last updated on :52:13 PM UTC

Making Adabot: Part 1

7 Portable Multitouch Raspberry Pi Tablet

Reindeer Mask with Animated Eyes

PyPortal View Master Created by Ruiz Brothers. Last updated on :51:28 AM UTC

Adafruit PowerBoost 500 Shield

DIY Circuit Playground Shields

Adafruit LED Sequins. Created by Becky Stern. Last updated on :00:06 PM EST

Adafruit Mini TFT " 160x80

i2c/spi LCD Backpack Created by lady ada Last updated on :11:04 PM UTC

Mystical LED Halloween Hood

Getting Started with FLORA

Mad Science Test Tube Rack

BLE Light Switch with Feather nrf52840 and Crickit

Webcam Cover-Up Lego brick with Adabot Mini Fig

NeoPixel Manicure. Created by Sophy Wong. Last updated on :50:38 PM UTC

Fiddy - the FTDI Clip

Trellis 3D Printed Enclosure

LED Breath Stats Mask

Data Logging with Feather and CircuitPython

Spinning Disc Step Sequencer

Bluetooth Controlled NeoPixel Headphones

Circuit Playground Combadge

Celebration Spectacles

3D Printed 20w Amplifier Box

Unicorn Hat with Moving Ears

Magical Mistletoe. Created by Leslie Birch. Last updated on :45:29 PM UTC

Secret Hollow Book Intrusion Detector

Fiddy - the FTDI Clip

NeoPixel Basketball Hoop

FPV Mini Display. Created by Ruiz Brothers. Last updated on :00:18 PM UTC

Joy Featherwing. Created by Dean Miller. Last updated on :03:07 PM UTC

Getting Started with FLORA

Adafruit MCP9808 Precision I2C Temperature Sensor Guide

Introducing Adafruit Trellis

Transcription:

Adabot Operation Game Created by John Park Last updated on 2018-08-22 04:11:17 PM UTC

Guide Contents Guide Contents Overview Parts Materials & Tools Build the Operating Table Print the Board and Pieces Mount the Board Cut the Openings Add Copper Tape Contacts Tape Connector Tabs Inner Boxes Add Circuit Playground Express Connect the Alligator Clips Game Pieces Code with CircuitPython CircuitPython Setup Code Code Breakdown Libraries Lists and Touchpads Color Lists NeoPixel Fill The Loop Threshold Tuning Code with MakeCode Getting Started with MakeCode Operation MakeCode On Start Per Pin Block Operate! 2 3 3 4 6 6 8 9 10 13 15 19 20 22 24 24 24 25 25 26 26 26 26 27 28 28 28 28 28 30 Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 2 of 32

Overview Adabot needs your help, Doctor! It's time to operate!! It takes a steady hand to remove the game pieces! You can build this fun, classic game using a Circuit Playground Express to react whenever your hand isn't so steady and your tweezers bump the edge of an opening. You'll build the board, and then program the Circuit Playground Express using CircuitPython or MakeCode to test the capacitive touch pads for contact. A tip of the hat goes to Maker Camp for their inspiring project (https://adafru.it/c9h) using the Makey Makey (https://adafru.it/eie) board. Parts To build this project you'll need the parts below, as well as a computer for programming and uploading code to the Circuit Playground Express. 1 x Circuit Playground Express Round, Awesome Microcontroller Board ADD TO CART 1 x Copper Foil Tape 25mm x 15 meter roll ADD TO CART 1 x Short Wire Alligator Clip Test Leads Set of 12 ADD TO CART Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 3 of 32

1 x 3x AAA Battery Holder with On/Off Switch and 2-Pin JST 1 x Alkaline AAA batteries 3 pack ADD TO CART ADD TO CART 1 x Black Nylon Screw and Stand-off Set M2.5 Thread ADD TO CART 1 x USB Cable A/MicroB - 3ft ADD TO CART Materials & Tools In addition to the parts listed above, you'll also need: Small cardboard box, such as an Adafruit shipping box Metal tweezers Color printer with white paper or cardstock Hobby knife or scissors Glue stick Scotch tape Small Philips screwdriver Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 4 of 32

Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 5 of 32

Build the Operating Table Print the Board and Pieces Use a color laser or inkjet printer to print the file linked here onto a piece of white cardstock. Be sure to print without any image scaling so that the parts will align. https://adafru.it/c9e https://adafru.it/c9e Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 6 of 32

The game board file looks different (better!) than the one used in some of these photos. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 7 of 32

Mount the Board Cut out the board image Glue it to the top of a cardboard box. An Adafruit shipping box may be large enough or find another box approximately the size of the board or larger. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 8 of 32

Cut the Openings Use a hobby knife to cut out the board image and cardboard lid of your box at all of the indicated "incision" points Also cut out the holes for the Circuit Playground Express mounting points and touch pads so we can connect alligator clips to them later from below the board Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 9 of 32

Add Copper Tape Contacts The copper tape is what we'll use to detect errant tweezers touches, by running it around the edges of each incision hole. Each tape site will be connected to the Circuit Playground Express via an alligator clip lead. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 10 of 32

Cut out a piece of copper tape that is just a bit bigger than the opening Press it down to fit and to indicate the hole below Slit the tape along the top and bottom edges Slit the tape vertically up the center as shown Push the two flaps down into the hole Repeat for each of the seven part holes Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 11 of 32

Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 12 of 32

Tape Connector Tabs Inside each taped hole, connect another short strip of copper tape as shown. This is where each alligator clip will connect. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 13 of 32

Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 14 of 32

Inner Boxes Next, cut out the papercraft boxes from the printed sheet. (Yours may vary in color from the ones shown here) Cut along the solid lines Fold along the dotted lines -- the outer set will be "mountain" folded to form a lip, the inner set a "valley" fold to form the walls -- see the picture for proper fold directions Tape the boxes under each hole as shown Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 15 of 32

Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 16 of 32

Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 17 of 32

Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 18 of 32

Add Circuit Playground Express You'll now add the Circuit Playground Express by fastening it to the board with four medium screws and nuts. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 19 of 32

Connect the Alligator Clips Follow the images here to connect the Circuit Playground Express capacitive touch pads to the copper tape tabs. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 20 of 32

Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 21 of 32

Game Pieces Glue the game pieces section of the printout to a piece of scrap cardboard Cut out the pieces with a hobby knife or scissors Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 22 of 32

If you'd like to 3D print pieces instead, you can download the attached model file. https://adafru.it/c9f https://adafru.it/c9f Next, we'll program the Circuit Playground Express in CircuitPython, or you can skip ahead to program it with MakeCode. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 23 of 32

Code with CircuitPython The key feature of Operation is that the lights and buzzers alarm whenever your tweezers touch the edge of a hole. We've connected the copper tape at each hole to a capacitive touch pad on the Circuit Playground Express -- now we want to code the board in CircuitPython to react. Jump ahead to the next page if you want to program with MakeCode instead. CircuitPython Setup To get started, you'll want to set up the Circuit Playground Express for use with CircuitPython by following this guide (https://adafru.it/afi). When you're ready, and can upload code to the board return here. Adafruit really likes using the Mu editor to edit the CircuitPython code. See this guide on loading and using Mu (https://adafru.it/ano). Code You can copy the code here and then paste it into Mu. Save it to your Circuit Playground Express as code.py Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 24 of 32

# Adabot Operation Game # CPX, alligator clips, copper tape, tweezers, surgery, and fun! import board import touchio from adafruit_circuitplayground.express import cpx # import time # uncomment if testing raw read values cap_pins = (board.a1, board.a2, board.a3, board.a4, board.a5, board.a6, board.a7) touch_pads = [] for i in range(7): touch_pads.append(touchio.touchin(cap_pins[i])) for touch_pad in touch_pads: touch_pad.threshold = 3500 # adjust value to fine-tune touch threshold MAGENTA = (10, 0, 10) VIOLET = (5, 0, 15) BLUE = (0, 0, 20) CYAN = (0, 10, 10) GREEN = (0, 20, 0) YELLOW = (10, 10, 0) ORANGE = (15, 5, 0) RED = (20, 0, 0) WHITE = (3, 3, 3) COLORS = [MAGENTA, VIOLET, BLUE, CYAN, GREEN, YELLOW, ORANGE, RED, WHITE] cpx.pixels.fill(white) while True: for i in range(7): # uncomment block to check the raw touch pad values # print("raw %s value for pad " % i) # print(touch_pads[i].raw_value) # time.sleep(.5) if touch_pads[i].value: # print("touched %s" % i) # uncomment for debugging cpx.pixels.fill(red) cpx.play_tone(660, 0.7) cpx.pixels.fill(colors[i]) Code Breakdown Libraries Here's what's going on in the code. First, we import the board, touchio, and adafruit_circuitplayground.express libraries. These give us the commands we need to address the board and it's capacitive touch pads, as well as the NeoPixels by using the cpx commands. (Note that the time library import is commented out, you will uncomment this if later you decide to check your raw touch values, which is covered later.) Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 25 of 32

import board import touchio from adafruit_circuitplayground.express import cpx # import time # uncomment if testing raw read values Lists and Touchpads Next, we'll create a list of the board's cap touch pins and initialize them as touchio touch pads. And, we'll set the touch threshold to 3500. This can be tuned later. cap_pins = (board.a1, board.a2, board.a3, board.a4, board.a5, board.a6, board.a7) touch_pads = [] for i in range(7): touch_pads.append(touchio.touchin(cap_pins[i])) for touch_pad in touch_pads: touch_pad.threshold = 3500 Color Lists We'll create a set of variables for different colors and their values. Then, we'll create a list of those colors called... COLORS. This way we can associate an index number for each touch pad to a color in the list. MAGENTA = (10, 0, 10) VIOLET = ( 5, 0, 15) BLUE = ( 0, 0, 20) CYAN = ( 0, 10, 10) GREEN = ( 0, 20, 0) YELLOW = (10, 10, 0) ORANGE = (15, 5, 0) RED = (20, 0, 0) WHITE = ( 3, 3, 3) COLORS = [MAGENTA, VIOLET, BLUE, CYAN, GREEN, YELLOW, ORANGE, RED, WHITE] NeoPixel Fill We'll then fill all of the on-board NeoPixels white with this command: cpx.pixels.fill(white) The Loop Now that everything is set up, we have the main loop of the program. What happens here is that we'll iterate through each of the seven pads, checking to see if their value is above the threshold. If it is, we fill the NeoPixels red, play a buzzer sound, and then fill the pixels to the color associated with that pad. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 26 of 32

while True: for i in range(7): # uncomment this block to check the raw touch pad values # print("raw %s value for pad " % i) # print(touch_pads[i].raw_value) # time.sleep(.5) if touch_pads[i].value: print("touched %s" % i) cpx.pixels.fill(red) cpx.play_tone(660, 0.7) cpx.pixels.fill(colors[i]) Threshold Tuning Note the section in the code above that is commented out. If you uncomment it by removing the leading pound symbols ( # ) you can watch the raw touch values being printed in the Mu REPL or other serial terminal connected to your Circuit Playground Express. Watch for the typical values when not being touched and then the values when they are touched. If, say, the pads typically read around 2000 but then shoot up to 4000 when you touch them with your tweezers, you could set the threshold to 3500. With the code uploaded to the board, you're ready to play! Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 27 of 32

Code with MakeCode If you'd prefer to code the Adabot Operation Game with MakeCode, this is the page for you! Getting Started with MakeCode If you're new to MakeCode, head to this guide to get started (https://adafru.it/wwd). Once you're able to upload MakeCode to your Circuit Playground Express, return here. Operation MakeCode The key feature of Operation is that the lights and buzzers alarm whenever your tweezers touch the edge of a hole. We've connected the copper tape at each hole to a capacitive touch pad on the Circuit Playground Express -- now we want to code the board in MakeCode to react. On Start First, we set all the pixels to white, with the set all pixels block from the NEOPIXEL category. Then set the capacitive touch threshold on all pins to 1000 with the button pin A1 set threshold 200 block found in the INPUT category. You can adjust this value as needed in case your tweezers aren't causing the copper tape and alligator jumper wire antennae to trigger! Per Pin Block The rest of the code is very simple! We're going to create an on button A click block from the INPUT category and then change it to on pin A1 down. This is how you can test a pad for a capacitive touch event. Inside this block we'll set the pixels red when the pad has triggered, and then play a tone. Finally, we'll change the pixels to a unique color, in this case, magenta. Simply duplicate this block six times, changing each one to use a different pad from A2-A7, and adjusting the colors. That's all there is to it! Click this button to open the live MakeCode session in your browser. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 28 of 32

https://adafru.it/c9u https://adafru.it/c9u Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 29 of 32

Operate! To play the game, plug in the battery pack and then turn it on. Load the pieces into their holes. Then, with a steady hand, try removing each piece using the tweezers! If you touch the sides and the buzzer goes off, your turn ends! See who can collect the most pieces. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 30 of 32

If your copper tape starts to oxidize and turn color, it may not pick up the tweezers touching the openings as it once did. You can take some very fine sandpaper or a fine nail file/buffer and gently rub the copper to get it shiny and conductive again. Adafruit Industries https://learn.adafruit.com/adabot-operation-game Page 31 of 32

Adafruit Industries Last Updated: 2018-08-22 04:11:12 PM UTC Page 32 of 32