Samuel FariesJeremy Brake
Published © GPL3+

The Blind Spotter

When you are practicing for your next long range competition use the blind spotter and you will never miss the impact again.

IntermediateFull instructions provided5 hours778
The Blind Spotter

Things used in this project

Hardware components

Internet Button
Particle Internet Button
USB-A to Micro-USB Cable
USB-A to Micro-USB Cable
Anker Power Core 10000 mAh Portable Power Bank
Magna-Arm Magnet Gun Mount
Bolo Brands N Wireless 18dbi 2.4GHz Wifi Antenna
U.FL Mini PCI to RP-SMA Pigtail Antenna Adapter

Software apps and online services


Read more


Blind Spotter Target Code

The code seen below is for the Internet button that is located on the back of the target. This code allows the internet button to detect acceleration in the Y direction. Based on the data being collected it will allow the button to publish a event called "Hit" or "Miss". This code also subscribes to a event published by the Blind spotter Button located beside the shooter. This is so that when the button in the 6 o'clock position is pressed, an event will be published so that the particle on the back side of the target will subscribe to letting it know to be looking for motion.
#include "InternetButton.h"
#include "math.h"

InternetButton Target = InternetButton();
int boardLed = D7;
int x = 0;
int y=0;
long start=0;
bool run = false;
int Hitcount=0;
void setup() {
                                                     //Tell b to get everything ready to go
                                                     //This switches the Antenna from the internal Antenna on the photon to the External Antenna purchased
                                                      //This sets a variable that can be called on in the particle console named yValue, and is used for comparison down later in the code
Particle.variable("yValue", y);
                                                     //This sets a variable that can be called on in the particle console named x, and is used for comparison against the y in the loop
Particle.variable("x", x);
                                                     //This function subscribes to the B3pressed publish that the other particle publishes when the button in the 
                                                     //6 o'clock postion is pressed on the other photon. Once it subscibes to the publish it runs the BlinkLED fuction stated later in the code.
Particle.subscribe("B3pressed", BlinkLED);

void loop(){

                                                     //This sets y value to the value that is outputted by Target.readY() which is an interger 
    int y = Target.readY();
                                                     //This sets the Y value that is called on in the console by the varible yValue
    y= Target.readY();
                                                      //This makes it where the acceleration in the internet button is only felt in the y direction 
                                                     //The absolute values are added because it doesn't like negitive values and for easy recording
  Target.allLedsOn(0, abs(y),0);

                                                     //This statement reads that is the time since the leds on the internet button has blinked is 
                                                     //less then 60 seconds and run is true then keep going to the next statement.
if (((millis()-start)<60000)&&run){

                                                     //The statement below says that the y value obtained above is greater or less then the x value obtained when the LED's are blinked 
                                                     //it will post Hit. A range of pluse or minus 1 was added so that if any slight movement from wind was detected it wouldnt publish Hit.
if ((y >(x+1)) || (y <(x-1))){
                                                     //publishs hit to the console which is subscribed by the other photon and changes the LEDs on that internet button green
    Particle.publish("Motion_alert", "Hit");
                                                     // Hitcount is reset to 0 evertime the 6 o'clock button on the other photon is pressed.
                                                     //This allows once the above is true the hitcount will go to 1. This will allow it to not to publish a miss since hitcount must equal 0.

                                                     //This allows 1 second delay before running the next function
                                                     //This has 2 statements that must be true before publishing
                                                     //The first Hitcount must equal 0 so if a hit is detected this will be false
                                                     //The second is the time must be greater then 60 seconds 

if ((Hitcount==0)&&(millis()-start)>60000){
                                                     //Both of the above statements must be true before the particle will publish a miss.
Particle.publish("Motion_alert", "Miss");


                                                     //This fuction is called on when the particle subscribes the Blind_spotter_shooter button 
void BlinkLED(const char *event, const char *data)
                                                     //if the data from the Blind_spotter_shooter button is ETA1min this it will blink all LEDs white on the Blind_Spotter_target starting the loop above 
  if (strcmp(data,"ETA1min")==0) {
                                                     //Allows the lights to stay on for 2 seconds 
                                                     //This will switchs the LED's off 
                                                     //While running this loop it will set start to millis so that it will still maintain the 60 second constraint
                                                     //Hitcount is reset to 0 everytime this fuction is run
                                                     //Records the x value which is used in the loop above to compare to the y value to know whether motion was detected.
                                                     //This does the same thing as the if statement above but for a different set of data that the Blind_spotter_shooter button publishes 
else if (strcmp(data,"startover")==0) {
                                                     // if the particle reads "Reset" as the event then it will turn on all LEDs Red

  else {
                                                     // if the data is something else, don't do anything.
                                                     // Really the data shouldn't be anything but those two listed above.

Blind Spotter Shooter code

This code is for the Internet button located beside the shooter. This code is designed so that when the button in the 6 o'clock position is pressed it will publish an event titled "ETA1min". This event will then be subscribed to by the internet button located on the the back of the target. This is letting that device know that the shooter is going to be firing a shoot in the next minute. If acceleration is detected within that 1 minute window, the particle on the target will publish an event called "Hit" which will trigger the internet button beside the shooter to turn green indicating a hit. If at the end of the 1 minute window motion is not detected and a counter is still at, zero meaning no hit was detected previously, it will publish an called "Miss". This will cause the LED's on the internet button located beside the shooter to turn red, indicating miss.
                                                   // This #include statement was automatically added by the Particle IDE.
#include <InternetButton.h>

InternetButton b = InternetButton();
 int Button3pressed=0;

void setup() {
                                                     // Tell b to get everything ready to go

                                                     //will allow the particle to subscribe to the particle that detects motion then runs the spotter fuction below to distinguish between data 
    Particle.subscribe("Motion_alert", Spotter);

void loop(){

                                                     // When you click the Third button (at the 6 o'clock position) let's turn that LED on
                                                     //sets all LEDs to white which is neutral and means that it is waiting on a publish even from the other photon
                                                     //if button 3 is pressed publish this to cloud
            Particle.publish("B3pressed", "ETA1min");

                                                     //when button 4 is pressed it turns all the LEDs off resetting it so that button 3 can be pressed again between shots 
                                                     //publishish a rest event stating that the particle has been reset and is ready to go

                                                     //defining spotter and how it should seperate the data coming in into either hit or miss
void Spotter(const char *event, const char *data)
    if (strcmp(data,"Hit")==0) {
                                                     //if motion is detected it will publish hit blinking all leds green 

  else if (strcmp(data,"Miss")==0) {
                                                     // if nothing is detected in 60 seconds it will publish miss 





Samuel Faries

Samuel Faries

1 project • 0 followers
Jeremy Brake

Jeremy Brake

1 project • 0 followers


Add projectSign up / Login