Anda di halaman 1dari 83

Candy Counterstrike

PROJECT REPORT

Prepared by

Clancy Jembia
Andrew Huntley
Narong Yi

SPRING 2017
For Professor Tippens

KENNESAW STATE UNIVERSITY


Candy Counterstrike

ABSTRACT

Candy Counterstrike is a small target game. The aim of the game is to hit a moving target and at
the end of the game, candy will be dispensed depending on the number of times the target was hit.
The game also saves high scores which can be reset. There are visual indicators like 7-segment
displays and an LCD screen which provide a user-friendly interface. The game is designed around
the Raspberry Pi which is the brain of the system that incorporates many components like switches,
LEDs, an LCD display, a DC motor, a Servo motor, and a force sensor to model an entertaining
experience. These are all embedded in a wooden enclosure which serves as the body of the project.
The programming of this project was done completely in C.

1
Candy Counterstrike

TABLE OF CONTENTS

ABSTRACT ...................................................................................................... 1

TABLE OF CONTENTS ...................................................................................... 2

LIST OF FIGURES ............................................................................................. 4

LIST OF TABLES .............................................................................................. 5

1. INTRODUCTION ...................................................................................... 6

2. OPERATING INSTRUCTIONS ..................................................................... 8


2.1. POWER ON AND SETUP ................................................................................................... 8
2.2. STARTING THE GAME ..................................................................................................... 9
2.3. PLAY A GAME ............................................................................................................. 10
2.4. HIGH SCORES ............................................................................................................. 12
2.5. ABOUT ...................................................................................................................... 12
2.6. RESET, EMERGENCY STOP AND MEMORY RESET ................................................... 13

3. TECHNICAL SPECIFICATIONS .................................................................14


3.1. RASPBERRY PI ............................................................................................................. 14
3.2. POWER ...................................................................................................................... 14
3.3. SWITCHES .................................................................................................................. 16
3.4. LEDS ........................................................................................................................ 18
3.5. LCD DISPLAY ............................................................................................................. 20
3.6. TARGET PAD ........................................................................................................... 21
3.7. SERVO MOTOR ............................................................................................................ 23
3.8. DC MOTOR ................................................................................................................ 26
3.9. WIRING ..................................................................................................................... 27

4. CONCLUSIONS .......................................................................................29
4.1. SUMMARY .................................................................................................................. 29
4.2. PROBLEMS ENCOUNTERED ........................................................................................... 29
4.2.1. Testing switches ..................................................................................................... 29
4.2.2. Motor design .......................................................................................................... 29
4.2.3. Pin damage ............................................................................................................ 30
4.2.4. Overcomplexity ...................................................................................................... 30
4.2.5. Construction ........................................................................................................... 30

2
Candy Counterstrike

4.2.6. Simultaneous delay and testing .............................................................................. 31


4.2.7. Handling high scores file ........................................................................................ 31
4.2.8. Target motion and sensitivity ................................................................................. 31
4.3. NEXT STEPS ............................................................................................................... 31

5. APPENDICES ..........................................................................................32
5.1. WIRING DIAGRAM ....................................................................................................... 32
5.2. FULL SCHEMATIC ........................................................................................................ 38
5.3. PARTS LIST ................................................................................................................. 45
5.4. CODE ........................................................................................................................ 49

3
Candy Counterstrike

LIST OF FIGURES

Figure 1: power supply and switch ................................................................................................. 8

Figure 2: debug phase, welcome message and main menu ............................................................ 9

Figure 3: "play a game" summary ................................................................................................ 11

Figure 4: high scores screen .......................................................................................................... 12

Figure 5: ABOUT screen .............................................................................................................. 12

Figure 6: RESET, MEMORY RESET and red EMERGENCY STOP buttons ........................... 13

Figure 7: Raspberry Pi and GPIO pins ......................................................................................... 14

Figure 8: power board wiring ....................................................................................................... 15

Figure 9: limiting switch on rail of target and front face switches ............................................... 16

Figure 10: limiting switches and front facing switches ................................................................ 16

Figure 11: wiring of front facing switches .................................................................................... 17

Figure 12: LED indicators ............................................................................................................ 18

Figure 13: schematic of shift register and BCD to 7-segment decoder for a pair of 7-segment
displays ................................................................................................................................. 18

Figure 14: LCD face and PCF8574 backpack with contrast potentiometer ................................. 20

Figure 15: wiring the LCD............................................................................................................ 20

Figure 16: force sensor.................................................................................................................. 21

Figure 17: wiring the ADC and sensor ......................................................................................... 22

Figure 18: wiring the servo motor ................................................................................................ 24

Figure 19: Servo motor attached to hold candy from falling on the ramp through the opening .. 24

Figure 20: motor and target coupling with limit switches ............................................................ 26

Figure 21: wiring samples............................................................................................................. 28

Figure 22: multi-color connectors ................................................................................................. 28


4
Candy Counterstrike

LIST OF TABLES

Table 1: difficulty settings and point summary ............................................................................ 10

Table 2: power calculation estimate ............................................................................................. 15

Table 3: ADC summary ................................................................................................................ 22

Table 4: candy reward system....................................................................................................... 25

Table 5: color coding scheme ....................................................................................................... 27

5
Candy Counterstrike

1. INTRODUCTION

This project is the summary of what we learned to get this far into digital 3. The experience to
build this project is what reinforces what we learned in this program. Of course, learning the
raspberry pi microcontroller is another experience on its own. This project takes in everything you
learn and is set up to be built in a timely manner simulating jobs in the real world. The project is a
success and a valuable experience for our future careers.

Dyspraxia is a brain based condition that makes it difficult for people to develop the basic motor
skills needed to get through the day. Tasks such as brushing your teeth, writing, or even walking
are all difficult to perform for people with this condition. [3] It is not something that can be
outgrown by kids; dyspraxia usually requires treatment in the form of physical therapy through
simple tasks

According to studies from Rochester University, simple video games that challenge the player to
aim for small dots or targets are presented before them. A marked increase in their ability to track
the dots was noted, but more remarkably, the test players motor skills increased in other tasks
such as driving, reading smaller print, and finding friends in a crowd. Daphne Bavelier, UR
professor of brain and cognitive science expert, recognizes this as probabilistic inference; it is the
ability for humans to constantly make decisions based on probabilities that they are constantly
calculating and refining in their minds [2].

Studies using a group of students from St. Marys High School noted that after a week of playing
games, the test subjects had a 14.87% increase in dexterity when using the Perdue Pegboard Test
which is typically used as a neuropsychological test for precise movements involving the hands,
fingers, and arms. [1]

Candy Counterstrike acts as a tool to hone your ability to perform certain tasks faster. As you
become better at playing under time constraints and a quicker target, you will be rewarded with
more candy from the dispenser. This emphasizes practice on quickening your motor skills to be
able to accurately hit the target under more straining circumstances.

As a whole, candy dispensers in some form are in the market everywhere; you can easily find them
in many public places including the mall, school buildings, and other shops. Despite this, the size

6
Candy Counterstrike

of most dispensers are typically at least 8 feet tall and take up quite a bit of room. You will very
rarely find one that doesnt occupy so much room. Candy Counterstrike is a much smaller unit
capable of providing bite size candy for those skilled enough to hit the target displayed.

Not only does it provide dispensing for candy, but also help in developing motor skills for those
in need. For children and adults alike, we hope to create a fun experience that rewards the user for
putting in the effort to improve.

7
Candy Counterstrike

2. OPERATING INSTRUCTIONS

2.1. POWER ON AND SETUP

Candy Counterstrike should be setup on a flat surface, preferably with its back to a wall. Before
powering on, make sure the closing lid is in place to protect the inner components of the project.
When playing the game, the user should stand about 6 inches from the front face of the structure
with his projectile in hand. Watch out for objects in the background which could be damaged from
miss hits.

After taking the proper precautions, make sure the power cord is connected to an appropriate
source then press the black switch located on the right side of structure to launch the game.

Figure 1: power supply and switch

8
Candy Counterstrike

2.2. STARTING THE GAME

After powering up the system, the project will go through a debug phase where the visual indicators
will be tested before displaying a welcome message. After pressing OK on the welcome screen,
the main menu will be displayed. Navigation on this screen is done with ease using the UP,
DOWN, and OK buttons.

Figure 2: debug phase, welcome message and main menu

9
Candy Counterstrike

2.3. PLAY A GAME

After selecting the play a game option from the main menu, a message will appear asking you
to select your settings. The settings are selected using the switches labeled TIME and SPEED.
These are three state switches which allow for very flexible difficulty settings. The number of
points per hit also vary depending on the settings chosen.

Table 1: difficulty settings and point summary

Switch TIME SPEED


Position Setting Points per hit Setting Points per hit
Top 90s +1 QUICK +3
Middle 60s +2 NORMAL +2
Bottom 30s +3 STATIONARY +1

Basically, the more time you get and the faster the game is, the more points you get.

After the settings have been selected, the green PLAY button is hit to start the game. Once this
button is pressed, the following will happen:

- LCD display will display chosen (time and speed) settings, points per hit and a hit counter.
- GAME START LED will light up.
- TIME LEFT 7-segment display will start counting down from the selected time.
- The target will start moving (if a non-stationary speed was selected).

While the GAME START LED is on, any hit on the target will increment the SCORE counter on
the top-left 7-segment display and flash the HIT LED.

Once the time is up, the LCD will display the score and prompt the user to input their name which
is done with ease using the UP, DOWN and OK buttons. After the name has been inputted, candy
will be dispensed from the candy dispenser depending on the score and the high scores will be
shown on the LCD.

10
Candy Counterstrike

Figure 3: "play a game" summary

11
Candy Counterstrike

2.4. HIGH SCORES

The high scores option from the main menu simply displays the high scores stored in the game.
When the game runs for the first time, a default set of high scores are loaded. While on this screen,
scrolling through the scores is easily done using the UP and DOWN buttons. The OK button is
pressed from here to continue.

Figure 4: high scores screen

2.5. ABOUT

The ABOUT option from the main menu is simply meant to show some information about the
project. When this option is selected, the LCD displays the names of the developers, the instructor
and the course information. The OK button is pressed from here to go back to the welcome screen.

Figure 5: ABOUT screen

12
Candy Counterstrike

2.6. RESET, EMERGENCY STOP AND MEMORY RESET

These buttons located on the front face of the structure are used for control of the system.

Figure 6: RESET, MEMORY RESET and red EMERGENCY STOP buttons

At any time, the RESET button can be pressed to reinitialize the system. Once this button is
pressed, the system will go all the way back to the debug and welcome phase. Holding this button
will cause the pi to reboot.

If the user wishes to reset the scores to the default scores, they can hold the MEMORY RESET
button for 3 seconds. The scores will be reset and the system will reinitialize.

In case of malfunction or any other kind of emergency, the EMERGENCY STOP button can be
pressed. This will stop all functioning and freeze the system. From this point, the reset can then be
pressed to reinitialize the system.

13
Candy Counterstrike

3. TECHNICAL SPECIFICATIONS

3.1. RASPBERRY PI

At the heart of this embedded system is the Raspberry Pi. This is the device that was used to
interface all the different components and bring the project to life. The Raspberry pi for this project
was a Raspberry Pi 3 running the latest Raspbian release. Due to the high number of components
to be interfaced and the GPIO pin limitation of the Pi, several techniques and technologies had to
be used to work around this limitation. The software was done entirely in C with great help from
the WiringPi and Pigpio libraries. The wiring of each section can be seen in more detail in the
appendix.

Figure 7: Raspberry Pi and GPIO pins

3.2. POWER

Designing a power supply for this system was key because under-powering such a system will
cause the project to fail. At the beginning of the project, a rough power calculation estimate was
done to determine approximately how much power would be needed for the system.

14
Candy Counterstrike

Table 2: power calculation estimate

Component Quantity Voltage (V) Current (A) Power (W)


Raspberry pi 1 5 1 5
ICs * 9 9 5 16010&' 240 10&+
LEDs * 30 30 5 1510&+ 7510&+
Servo motor 1 5 0.5 1.6510&+
DC motor 1 12 0.5 6
Total: 11.23

Based on these calculations, a 12V3A=36W supply was chosen to supply the project and account
for any unforeseen power demands.

The 12V supply was converted to 5V for the pi using a 5V-3A DC-DC converter. Fuses were used
to protect the rest of the circuit from surge currents. The wiring of the power board can be seen in
the figure below:

Figure 8: power board wiring

15
Candy Counterstrike

3.3. SWITCHES

Figure 9: limiting switch on rail of target and front face switches

The switches are an integral part of the project as they are the main way in which the user interacts
with the project. Given how many they are (15 in total), it would be impossible to connect them
directly to the Raspberry Pi and have enough pins for the rest of the project. As a result, we chose
to use the MCP23017 which is an i2c port expander IC.

In terms of software, the WiringPi GPIO utility was useful in setting up the port expander once its
address was found. The switches were all connected one pin to ground and the other to an input
pin, (figure 11), with the internal pull-up resistors enabled. This made for an active low input logic
on the front board switches. The limiting switches on the motor rail were connected in a similar
manner, only directly to the GPIO pins of the Pi. The high speed of the processor made it easy to
miss a press of a button. As a result, a delay sub routine was used to continuously test a switch.
Refer to the appendix for more details on wiring and code.

Figure 10: limiting switches and front facing switches

16
Candy Counterstrike

Figure 11: wiring of front facing switches

17
Candy Counterstrike

3.4. LEDS

Figure 12: LED indicators

In terms of LEDs, there were 4 7-segment displays (2 for time and 2 for score count) and 2
indication LEDs making a total of 30 LEDs. Again, connecting all these directly to the Pi would
make the project impossible. As a result, we decided to use the 74HC595 shift register with the
74LS47 negative logic BCD to 7-segment decoder chip as the 7-segment displays were common
anode.

The 74HC595 accepts serial input from the Pi and puts it out in parallel on its 8 output pins. Four
of these outputs were input to a 74LS47 which takes BCD input and outputs the correct 7-
segment signals. Given that we had four 7-segments, two shift registers and four BCD to 7-
segment decoders were used. Figure 13 shows the schematic for these parts. In the code, the
switches and LEDs were combined.

Figure 13: schematic of shift register and BCD to 7-segment decoder for a pair of 7-
segment displays

The following snippet of code shows how these components were initialized.

18
Candy Counterstrike

19
Candy Counterstrike

3.5. LCD DISPLAY

A 20x4 (20 column 4 row) LCD was chosen for this project as an interface to users. It displays
key information and options which users can select using the UP, DOWN and OK navigation
buttons.

To reduce the pin consumption, the LCD was hooked up with i2c with the pcf8574 IC mounted as
a backpack on the LCD. Mounted on the front panel of our project, the viewable screen pokes
out of the wooden board. At the back of the LCD is a potentiometer used to vary the contrast of
the LCD to an acceptable value. The wiring of the LCD can be seen in figure 15.

Figure 14: LCD face and PCF8574 backpack with contrast potentiometer

Figure 15: wiring the LCD

The following snippet of code shows the setup of the LCD module. The rest of the code can be
seen in the appendices section. In the case of the LCD, the WiringPi library was of key importance
as it comes with many of the necessary functions built in. Note that the LCD operated at a voltage
of 5V which means that it cannot input data to the Pi as that would exceed the 3.3V input limit and
possibly damage a Pi pin. As a result, the RW pin was set permanently to high.

20
Candy Counterstrike

3.6. TARGET PAD

The target was implemented using a force sensing resistor. The force sensor used in this project is
simply a resistor whose value changed as it was pressed. Being a variable resistor, its resistance
(or amount of force applied on it) could be converted to an analog voltage signal by using a simple
voltage divider configuration. The analog signal was then fed to the Pi through the MCP3008 chip
which is an 8-channel 10-bit ADC with SPI interface. the wiring can be seen in figure 17.

Figure 16: force sensor


21
Candy Counterstrike

Figure 17: wiring the ADC and sensor

The design of the ADC can be summarized in the following table:

Table 3: ADC summary

Parameter Range
FSR resistance Infinity (open circuit) - 253
Input voltage 0 3.5V
Reference voltage 0 3.3V

As seen from the table, the input voltage closely matches the voltage reference but goes a little
above it. This was no issue since the force sensing resistor was only used to pick up the slightest
hits which meant the higher voltage (force) values were of little interest.

The following snippet of code shows how the ADC was setup. More details in the appendix.

22
Candy Counterstrike

The target pad consists of an ADC pressure sensor that tracks any target hits from a projectile.
Once a hit is detected, the HIT light brightens and the score on the 7 segment LED increments

The target is built with the sensor placed on a wooden board that resembles the shape of the target
pad. This board is then attached to a plastic tube where the wires are attached from the sensor
wired through the tube and then connects to our middle board on the top of the project.

3.7. SERVO MOTOR

For the function of dispensing candy, precise movement was needed to control exactly how much
to give out. For this reason, a servo motor was used to accurately position a panel that would
control the flow of candy depending on the number of points scored. For this reason, we decided
to use a servo motor. With this, it was possible to control precisely the number of spins; with the
Pigpio library, control of the position with PWM signals was a mundane task. The connection to
the Pi was done quite simply as seen in figure 18.

23
Candy Counterstrike

Figure 18: wiring the servo motor

Figure 19: Servo motor attached to hold candy from


falling on the ramp through the opening

The more complicated part was mounting this motor as part of the design for the candy dispenser.

The Candy Dispenser is the reward function of this project. When the user satisfies the conditions
of the game, candy is served through a dispenser. This dispenser is being controlled by a servo
motor. The number of spins on the servo motor is determined by the users score and time allotted
which also correlates to how much candy can come out. When the dispenser is not in use, it is in
its reset position which blocks candy from falling out.

24
Candy Counterstrike

The Candy Dispenser is a reward function. After the game is done, candy is dispensed depending
on the players score. The number of spins on the servo motor determines how much candy will
come out. The reward system is summarized in the following table:

Table 4: candy reward system

Points Number of spins


Less than 10 0
Between 10 and 30 1
Between 30 and 50 2
More than 50 3

The candy dispenser is located away from most electrical devices. It is built with a ramp that will
stop candy from being stuck in the back. It is supported by walls so the candy cannot spill out into
the project. The servo motor is located next to a hole on the wall where a piece of wood is glued
onto the base to keep the right height. The servo motors propeller is attached to a rectangular piece
of wood which acts as the blades that dispense the candy. When the dispenser is not in use, it is in
its reset position which blocks candy from falling out.

The code associated with the servo motor was combined with the DC motor code. More details
about the schematic and code can be found in the appendix.

25
Candy Counterstrike

3.8. DC MOTOR

The DC motor in the project is used to make the motor move. The motor is mounted on a flat
platform and firmly held in place. The rotor of the motor is then coupled to a threaded rod through
a wooden block. Attached to the threaded rod are two bolts which carry the target. As a result,
when the motor spins, the bolts carry the target linearly. Limiting switches are attached at the ends
of the targets path. These switches are used to keep the target from going out of bounds.

Figure 20: motor and target coupling with limit switches

Due to the inductive nature of the motor as an electric load, a high current is needed to drive it
properly. Such a high current coming out of the Pi will more than likely cause damage to the Pi
(we tried this). Consequently, we decided to use the LD293D which is an h-bridge motor driver
with a maximum output current of 600mA. Given that the operating current of the motor we
chose was 400mA max, this was largely sufficient.

In terms of software, controlling the motor simply meant outputting a high on one of the motor
driver inputs with the other one low. To control the speed, however, we used a PWM signal to
drop the effective voltage. The following snippet of code shows how the motor was controlled.
The wiring of the motor can be seen in the appendix.

26
Candy Counterstrike

3.9. WIRING

The wiring of the project was done on boards whose functions are documented in the appendix
section. Appropriate soldering techniques were used as well as the following color coding scheme:

Table 5: color coding scheme

Voltage level Color


0V Black
5V Red
12V Blue
< 3.3V Yellow

The interconnections between boards was done using ribbon cable connectors of various colors.
These are all documented in the wiring diagram under the appendices.

27
Candy Counterstrike

Figure 21: wiring samples

Figure 22: multi-color connectors

28
Candy Counterstrike

4. CONCLUSIONS

4.1. SUMMARY

Candy Counterstrike was intended to be a game that tests the users ability to accurately aim and
shoot a projectile at a target. Through the use of several navigational buttons and switches
combined with an LCD terminal, a lucrative system that was designed to keep track of the users
scores and to dispense a reward based on the number of points scored was developed.

The formation of Candy Counterstrike was an overall success. A functioning target that accurately
recorded the users current score and time was created. All components were fully functional
except for a few problems encountered.

4.2. PROBLEMS ENCOUNTERED

4.2.1. TESTING SWITCHES

One of the first problems encountered was testing switches. Due to the high speed of the processor,
it was easy to miss when a button was pressed. As a result, we resorted to using a delay sub-routine
to continuously test an input. A delay that was too long, however, would cause awkward waiting
times so the delay had to be optimized depending on the function.

The delay we ended up using worked well for most functions but could be better. In our opinion,
it would be best to use an interrupt sub routine to test switches to provide the optimal user
experience.

4.2.2. MOTOR DESIGN

The motor used at the end of the project was not the motor we initially selected. The first one was
a 6V motor with little torque. Although its speed was high, it was not able to move the target. From
here, we realized that the speed isnt the only thing important when picking a motor; the load

29
Candy Counterstrike

torque is important as well. We ended up upgrading the supply form 5V to 6V and getting a
stronger motor.

4.2.3. PIN DAMAGE

The afore-mentioned inappropriate motor design caused damage to the Pi which we had hard times
detecting. Some pins of the Pi were somehow damaged and some serial components (ADC and
shift registers) malfunctioned. This caused the force sensor to be unresponsive and the motor
direction could not be reversed while a set of 7-segment displays displayed garbage. After days
of frustration not knowing where the problem was, we were able to solve the problem by doing
several multi meter tests and ultimately replacing the Pi. For a long time, we doubted the code and
soldering while the actual hardware was faulty. Multi meter testing came in very handy during
these times.

4.2.4. OVERCOMPLEXITY

If you noticed, many different combinations of technologies (SPI for the ADC and 7-segment
displays, I2C for the LCD and port expander). Although this afforded us the opportunity to work
with more tools and learn more, everything would be simpler and faster if one uniform solution
were applied, preferably I2C due to the low number of pins needed (2 pins from Pi).

4.2.5. CONSTRUCTION

One problem our group found especially challenging was constructing the project. Neither of us
really had any experience building such structures so doing it for the first time was not an easy
task. We were able to manage by using the wood shop at the architecture building which we found
to be a great resource: without it, this project wouldnt have been the same. Construction material
could be found at Home Depot.

30
Candy Counterstrike

4.2.6. SIMULTANEOUS DELAY AND TESTING

This problem came up when coding the actual game. We needed to make the game run for the
number of seconds chosen by the user while testing the sensor and limiting switches at the same
time. The problem with this is that the timer is done using the delay() function from the GPIO
library. During a delay, the microprocessor just does nothing so it is impossible to delay and test
inputs at the same time in a single function. To solve this problem, we resorted to using threading
where one function would handle the timing and another function would handle the testing. The
two would communicate using a global variable: when the testing starts, the testing function sets
it and when the time is up, the timing function resets it. This can be seen in more detail in the code
appendix.

4.2.7. HANDLING HIGH SCORES FILE

To manage high scores, a file was used where new scores would be written and could be retrieved
later. We could successfully write and read from the file but the problem was that after reboot or
re-initialization, the file would get corrupted and contain garbage. Consequently, what we did was
create the file (if it didnt exist) and write default scores to it at every run. We plan on doing more
research on this since we were pressed for time toward the end of the project but we believe the
key is using a .txt file instead of a .dat file which we used.

4.2.8. TARGET MOTION AND SENSITIVITY

The design we used for our moving target was not optimal: the target made a lot of noise when
moving and did some front and back jerking. In addition to that, it was also very slow. The target
pad also had a sensitivity issue where it would not record the slightest hit. The solution to all this
is to use better equipment to design the moving parts perfectly and use a more sensitive sensor or
even a Hall Effect Sensor with metal projectiles.

4.3. NEXT STEPS

31
Candy Counterstrike

Increasing the size of the candy dispenser may be warranted for future designs; only candy
approximately 2-3 inches in size can properly fit. In addition to this, a design that does not
implement a large winding rod would allow for quicker and smoother movement of the target
while needing less torque to actually move the target.

5. APPENDICES

5.1. WIRING DIAGRAM

Switch board

32
Candy Counterstrike

Board Description and contents


AC Circuit to convert AC signal from wall to DC
Power Switch to allow power to system
switch
Power Power distribution board with fuses and voltage regulators
circuit

J1 1 External 12V
2 External GND
J2 1 5V
2 GND
J3 1 5V
2 12V
3 GND
Raspberry Embedded system used for control.
pi J1 1 5V
2 GND
J8 and others See Raspberry Pi specifications
Breakout Main board which interfaces different components like the pi and LEDs
board J1 1 5V
2 12V
3 GND
J2 See Raspberry Pi data sheet
J3 1 GND
2 ADC Digital in
3 ADC Serial Clock
4 ADC Chip select

33
Candy Counterstrike

5 3.3v
6 Led 2 control
7 ADC Digital Out
10 Led 1 Control
J4 Connector to the 74HC595, an 8-bit serial-in/parallel-out shift
register to interface 7-segment displays for time
2 5V
3 GND
4 Shift register 1 data
5 Shift register 1 latch
6 Shift register 1 clock
J5 Connector to the 74HC595, an 8-bit serial-in/parallel-out shift
register to interface 7-segment displays for score
2 5V
3 GND
4 Shift register 2 data
5 Shift register 2 latch
6 Shift register 2 clock
J6 Wires for LCD display interfacing. See LCD datasheet.
J7 Connectors for the momentary and fixed switches

1 Soft reset button


2 Speed select: stationary
3 Duration select: 60s
4 Duration select: 30s
5 Up button
6 OK button
7 Speed select: fast

34
Candy Counterstrike

8 Memory reset button


9 Down button
10 GND
11 Emergency stop button
13 Duration select: 90s
14 Speed select: slow
J8 12v DC to control the target
1 Motor Control pin 2
2 Motor Control pin 1
3 Limiting Switch 1
4 Limiting Switch 2

J9 3.3v Servo motor used to dispense candy


1 5v
2 GND
3 Servo Motor Control
LED and Board to interface motor and LED indicators
DC motor J1 1 GND
board 2 Data In
3 Clock
4 Chip Select
5 3.3v
6 Game LED
7 Data Out
8 12v
9 5V
10 HIT LED
J2 1 Motor Input 1
2 Motor input 2

35
Candy Counterstrike

3 Left limiting switch


4 Right limiting switch
J3 1 Right limiting switch
2 GND
J4 1 Left limiting switch
2 GND
J5 1 Motor driver output 2
2 Motor driver output 1
J6 1 Force Sensing Resistor
2 Analog input (5V)
7-segment Board to interface pi to 7-segment displays for time
interface
J1 1 5V
(time)
2 GND
3 DS serial input
4 MC reset shift register
5 OE output enable
6 SHCP shift register clock
7 STCP storage register clock
J2 Wires to control 7-segment display segments
7-segment Board to interface pi to 7-segment displays for time
interface
J1 2 5v
(score)
3 GND
4 Data In
5 Latch
6 Clock
J2 Wires to control 7-segment display for time
LCD
board LCD Board to navigate game and store high scores
J1 1 GND

36
Candy Counterstrike

2 5v
3 SCL
4 SDA
Switch Interface circuit for front panel switches as well as servo motor for candy
and servo distribution
motor J1 1 5V
board 2 GND
3 Signal for servo
J2 1 5V
2 Signal for servo
3 GND
1 Up button for selection
2 Ok button to validate selection
3 Down button for selection
4 Game start button
5 Emergency stop button
6 Speed selection switch
7 Duration selection switch
8 Memory reset button
9 Soft reset button

37
Candy Counterstrike

5.2. FULL SCHEMATIC

38
Candy Counterstrike

39
Candy Counterstrike

40
Candy Counterstrike

41
Candy Counterstrike

42
Candy Counterstrike

43
Candy Counterstrike

44
Candy Counterstrike

5.3. PARTS LIST

Reference Part Name Reference Part Number Qty Total


Description
Name Number Cost($)
Pushbutton

Momentary Switches (Includes Push switches used 48-1-RB-N- SW1-SW7 1 6.77


Switches multiple in 1 to navigate game BK-B
package)
Adafruit Industries
Single pole- Breadboard- Sets amount of
triple throw time for game and 805 SW8/SW9 2 4.00
friendly SPDT
Switch speed of target
Slide Switch
Double Digit 7 segment LED Displays time left
7-segment and score during HDSP-521E 7S1-7S2 2 3.30
Display
LED display game activity
Displays when a
hit is registered
Assorted pack of 25
LEDs and when the LS 000016 LED1/LED2 2 7.99
LEDs
game is currently
running
IC used to add
Serial Decoder/Demultipl additional outputs U5-U8 4
Parallel out SN74LS47N 7.04
exer for 7-segment
ports
display
Touch ADC FSR1 1
Target pad MCP3004 2.20
Sensor
3-Terminal Positive Steps down 5v
5v Voltage DCC1 1
source for use with NTE960 1.99
Regulator Voltage Regulator
LCD
Adafruit Pi T-
Brings the pins
Cobbler Plus Kit from the raspberry Breakout board
Cobbler 1989 1 7.50
Breakout for 2x20 pi to the breakout J2
Raspberry Pi board

45
Candy Counterstrike

Reference Part Name Reference Part Number Qty Total


Description
Name Number Cost($)
LCD 2004 smart Displays high
LCD score and menu for 2004 LCD2004 1 9.98
display
gameplay
Servo generic Used to dispense
Servo N/A 1
candy after score ROB-11965 12.95
Motor(6v) high torque
is calculated
Reversible 37mm
12V DC 15 RPM
DC Motor Gear-Box Speed Moves the target N/A 1
ZGB37RG 15.99
(12v) pad
control Electric
Motor

Power NTE Electronics ON/OFF switch


54-500 SW10 1 2.49
Switch Rocker Switch for the system
Ribbon Cables /
Ribbon Connectors for
IDC Cables Ribbon CON-243-
Cables/Con LED, Switch, and N/A 11 21.60
Cables / IDC CON248
nectors other boards
Cables 10-pin
Adafruit Industries Changes direction
Trigger Breadboard- of target pad
54-402 SW10/SW11 2 3.49
switches friendly SPDT movement when
Slide Switch pressed
PCBs &
Breadboards PCBs Holds circuit
& Breadboards components for
Breadboard 8015-1 N/A 6 43.98
CIRCBD,PAD- sections on the
PER-HOLE 4.0"X model
4.0" X .062"
Electrical
100 ohm (13), 470
Resistors component that 100EP514100R R1-43 43 11.99
ohms (x28), 560
resists flow of

46
Candy Counterstrike

Reference Part Name Reference Part Number Qty Total


Description
Name Number Cost($)
ohm; set of 610 electricity; protects
resistors circuit components
Prevents current UHE1H471MH
Capacitors 470 uF U2/U3 1 1.64
from surging D6
Provides extra I/O
Port Microchip I/O
ports for the MCP23017 U1 1 1.26
Expander expander
Raspberry Pi
Used to
Motor Dual H-bridge circumvent current
LD293D U3 1 2.95
Driver motor driver drained by motor
usage
System used to
Raspberry Raspberry Pi 3 develop and
DEV-13825 N/A 1 49.93
Pi 3 Model B control all external
inputs/outputs
12v 3A
Polycom 12V Power supply for 2200-17568-
power N/A 1 14.95
Power Supply the system 001
supply
Used to balance
1 in x 2ft PVC
PVC pipe and support target 25609 N/A 1 3.23
pipe
pad system
Used as a general
JH 46 Loctite
Super Glue adhesive for parts 176218 N/A 1 3.98
Gel Ultra
of the project
Ply Wood Underlayment 7/32 Used as framing
431178 N/A 1 11.99
Sheet in. x 4 ft. x 8 ft for the design
Use to secure the
90 Degree
Stan 1 IN structure of the 102894 N/A 12 22.56
brackets
box

47
Candy Counterstrike

Reference Part Name Reference Part Number Qty Total


Description
Name Number Cost($)

Total: $275.72

48
Candy Counterstrike

5.4. CODE

49
Candy Counterstrike

50
Candy Counterstrike

51
Candy Counterstrike

52
Candy Counterstrike

53
Candy Counterstrike

54
Candy Counterstrike

55
Candy Counterstrike

56
Candy Counterstrike

57
Candy Counterstrike

58
Candy Counterstrike

59
Candy Counterstrike

60
Candy Counterstrike

61
Candy Counterstrike

62
Candy Counterstrike

63
Candy Counterstrike

64
Candy Counterstrike

65
Candy Counterstrike

66
Candy Counterstrike

67
Candy Counterstrike

68
Candy Counterstrike

69
Candy Counterstrike

70
Candy Counterstrike

71
Candy Counterstrike

72
Candy Counterstrike

73
Candy Counterstrike

74
Candy Counterstrike

75
Candy Counterstrike

76
Candy Counterstrike

77
Candy Counterstrike

78
Candy Counterstrike

79
Candy Counterstrike

80
Candy Counterstrike

81
Candy Counterstrike

82

Anda mungkin juga menyukai