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
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 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
Step 6: Electronic Controls
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
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.