For this year’s Trunk ‘O’ Treat game I wanted to make a something fun and exciting for kids to play so I choose a Whac- a-Mole type game called Whac-a-Veggie using the Veggie Tales characters.
The Whac-a-Veggie game is played with a foam hammer in your hand and the veggie characters randomly popping-up quickly and you have to hit them on the head before they go back in there holes to score a hit, the one with the most hits wins. The PIC microcontroller controls the game action with air cylinders that push the veggies up and down by the use of an air solenoid. A timer keeps the game time to 35 seconds long and the score board counts the number of veggies you hit in the game.
Step 1: Design and Operation
The Whac a Veggie game has to maintain the following list of game requirements for reliability and game operation. The game starts off by clearing the score for a new game and keeping score during the game with every hit. Start a timer for a preset game time and the timer stop the game when the time is expired. The veggies need to pop-up randomly during the game. The veggies must not rotate when hit so we have to design the hardware to keep the veggies looking forward at all times. The game must me made strong enough to take the many hard hits with the hammer. The relay, air cylinders, and solenoids need to move the veggies up and down quickly to have good game to player response for game fun.
PIC 18F4550 PIC
40 Pin PIC Development Board # DEV-00021 (Spark Fun)
ATX breaker board #BOB-09558 and ATX connector #PRT-09498 (spark fun)
Bimba Air cylinder 6” travel #BF-096-D
MettleAir pneumatic valves 5/2 way 4A210-08 12VDC (Pneumatic Products)
Brass air Silencer for exhaust air 1/8” (Pneumatic Products)
Tubes thread fittings 1/4” #S1/4-N02 (poweraire.com)
Tube male elbow fittings 1/4” #E1/4-N02 (poweraire.com)
Union straight speed controller #USC1/4 (Qty-6) (poweraire.com)
Triple branch union #TUBU1/4(Qty-2) (poweraire.com)
20MHZ crystal oscillator
Timer MX024 Digital Timer (Bakatronics)
Relay module board, eight channels, for PIC, songle electronics (eBay)
ATX breakout board and connector # BOB-09558 and PRT-09498.
Resistors: 1K, 100, 10K, 470 ohm,
Capacitors 4.7uf, .1uF
Counter Display #G16774 (goldmine electronics)
ATX power supply connector 12v, 5v power for control and lights.
Blank PCB proto boards
74LS08 AND gate
Mechanical hardware springs, 6-32 bolts, 1/4”-20 bolts, 8-32 bolts,
Step 2: Construction-Cabinet
The cabinet base is 30”L X 30”W x 27-1/2”H by and the display board is 30”L x 5-1/2”W x 73”H. The cabinet base is constructed out of 2x4 boards at the corners and 1x2 with the main deck with 3/4” particleboard on top. The veggie bases are attached to the underside of the main deck of the cabinet by mounting bolts. The veggie basses and the main deck holes must all line up for the machine to function correctly. To maintain perfect alignment of all the holes. I temporally screwed the top and bottom veggie base plate boards to the underside of the main deck. Follow the dimensions shown on the layout drawing for drilling. Label and mark all boards for top, bottom, number, location, front, and back for maintaining perfect hole alignment for assembly. Once all the 1/4”-20 holes are drilled on the main deck you can remove the labeled wood veggie bases. Now you can drill with a hole saw the 4-1/2" diameter pop-up holes on the top of the main deck.
Step 3: Construction-Veggie Bases and Characters
The veggie base needs to be securely built to take the abuse of being hit. The veggie bases provide support for the air cylinders and veggie characters. The veggie bases consist of a top plate and bottom plate of that are held together with the 1/4”-20 all thread. The top and bottom base are constructed from 3/4” thick particleboard and are 7”w x 10”L in size. The veggie bases are mounted to the underside of the main deck of the cabinet base via the mounting bolts.
The metal support bracket that are attached to the air cylinder which provides the support for the switches, rotation guides, and springs for keeping the veggie characters looking forward. The rotation guides are located on the bottom of the veggies, by the switches, rotation rod. All this was added to prevent the veggies from rotation when hit and going up and down. An additional metal guide was attached to the front of each veggie to prevent characters from rotating. The blots (6-32) by the metal springs keep the spring form rotating.
The veggies characters are standard stuffed plush toys. I removed the most of the stuffing so I could insert the 1-1/2” square hardwood table leg. The hardwood was cut to lengths and then drilled in drill press for the plastic bushing that was glued with epoxy inside so it will slide easily on the 5/16” all thread shaft support shaft. The plastic bushing with the spring was glued with epoxy together in place.
Step 4: Construction-Main Deck
The main deck is where the all the veggie bases mount to by the 1/4”-20 mounting bolts. When the heights are set on all the veggies you use your Dremel tool to cut the all-thread flush with the nuts. Use the Dremel tool to grind the cut metal smooth with no sharp edges. Put lock tight or nail polish to keep the nuts from loosing. Put Duct tape over the nuts so they will not cause a electrical short when the hole lights are installed.
LED Hole Lights:
Paint around the veggie holes with black paint on the inside edge and one inch around the hole. To make the LED hole lights you take a qty12- 5mm white LED’s and solder them to make two wire rails in a circle with 470 ohm resister on the anode lead of the LED. I put clear packing tape to keep the positive and negative wires from touching and shorting out. The LED hole lights are glued down to the main deck with silicone glue. The LED power supply wires are going through a hole drilled in the main deck and connected to 5VDC. The lights make it easier/better to see the veggies at night during Trunk ‘O’ Treat.
The green carpet is placed on the main deck and with a sharp knife you cut the holes out without moving the green carpet from the main deck. When ready you glue down the green carpet with silicone glue put some heave height on the carpet so it will glue down flat and smooth. The green carpet wraps around the top edges 2” down and is glued down this silicon glue and stapled to keep in position.
Step 5: Construction-Display Board
The display board is 30”L x 5-1/2”W x 73”H. The Display Board is attached to the back of the cabinet base by screws. The display board is made from 1”x2” and 2”x4” wood boards make up the frame structure. White poster boards is used for filling in making a shadow box type display, the outer lip is 3-1/2” wide for the top, right, and left sides. I installed white 5mm LED’s on the inside lips pointing inward to illuminate the veggie posters. The score display is mounted in the upper middle of the display board back. I used Duct tape to keep the seams together and provide a cover over the display board circuit.
Step 6: Electronic Controls
The PIC18F4550 microcontroller controls the game operation. The game has two game speeds fast and slow. I generally use the slow speed because it is fast enough. With the switch in the fast position in gives a logic high (1, 5VDC, VCC) to the PIC RE0, slow is logic low (0, 0VDC, VDD, ground). When you press the start button, the PIC is reading pooling the RE2 bit for logic high to start the game. With the game started the PIC will clear the score by the closing and open a relay. The score display board (Counter Display #G16774 (goldmine Electronics)) is cleared by a dry contact closure.
The PIC will output (RC0) a logic high bit to the inverter IC 74LS04 to invert the logic high to logic low to the Timer Card (Timer MX024 Digital Timer (Bakatronics)). The timer card will start the time sequence with a logic low. The timer card has a relay that is opens when the time is complete and closed when running. Because of this setup we wire VCC with a 100 ohm resister o the NO position on relay and wire ground to the common terminal of the relay with will give us the proper logic for game done operation. With the timer on (running) we output a high bit to RC0 for timer Interrupt enable gate IC AND GATE 74LS08. We only want an interrupt to happen when the game is running.
Now the code in the PIC will determine a random number and goto the lookup table to output a logic high to PortD RD0, RD1, RD2, DR3, and RD4 to pop the veggie up. The output from the PIC goes in and out the optocoupler IC 4N35. The optocoupler electrically isolates the PIC from the electro mechanical components due to noise and EMF feed back with relay and solenoid are operating. The high output from the optocoupler 4N35 drives the relay board to activate the relay and send +12vdc to power the air solenoids. (MettleAir pneumatic valves 5/2 way 4A210-08 12VDC (Pneumatic Products)) the air solenoids send air pressure to the air cylinder (Bimba , Air cylinder 6” travel #BF-096-D) this cause the veggies to go up and when the PIC is complete with the small time delay in the code it will clear PortD Logic low and the optocoupler, relay, and air solenoid will de-activate and the veggie character will go down. The PIC will go through with routine over and over until the timer is complete with a high bit on interrupt PortB RB0 to stop the game and clear PortD. In the interrupt code routine we clear files and setup the game for a new game and keeping the existing score displayed.
The score display is powered by the included ac-dc adapter. The score display functions by dry contact closures for counting up and clearing the score. To clear the score we use a relay that wired to the two red wires the relay is controlled by the PIC for operation. To count up the veggie hit wires are all wired in parallel to the two black wires to make the closure need to count up on the score board.
The timer card is set to a programmed time that is set by you for the number of second you what the game to run. I used 35 sec for game time. To start the timer it requires a logic low (0) to terminal #1. We use an inverter to invert the high bit from the PIC to a logic low to start the timer. The timer has a relay that opens when the time is complete and closed when the timer is on (running). To use the timer relay to signal the PIC when the game is over we wire VCC with a 100ohm resister to one contact and ground to the other contact. The output from the relay logic high is wired to the two input AND gate and the PIC will enable the other AND gate input when we only what to see game over when the game is running.
Step 7: Software Design and PIC CODE
The flow of the Veggie CODE does the following:
Speed switch is selected, Input (RE0) (Logic high fast, logic low slow)
Start Button is pressed, Input (RE2) (Logic high to start)
Score clear logic high, Output (RC7)
Start timer Logic high, Output (RC2)
Enable AND gate for Interrupt logic high, Output (RC0)
PIC loads rand file with random number to goto lookup table to output to PortD with a random veggie to pop-up and goto speed delay function to keep the veggie up for delay time then clear PortD to bring the veggie down. The PIC does this routine over and over until the timer times out and an interrupt (RB0) to the input of PIC to stop the game.
After the interrupt it will clear the files and setup the game for the for the next game
The Score remain as shown until the next game when the start button is pressed again.
Step 8: Movie
In conclusion the Whac a Veggie was a huge success the night of Trunk ‘O’ Treat 2010. The project took longer than I thought. It took around 400+ hours to design and construct the game all from scratch. I hope many will enjoy this instructables on the Whac a Veggie game and enjoy the movie.
Participated in the
Duct Tape Tough Contest
Participated in the
What Can You Do with a Dremel Tool?
Participated in the
Kinetic Sculpture Design Contest