Motorized shooting target

Shooting pistol is fun for a first few hours. Then it is boring. How about shooting a moving target? Sounds like fun!

Here it is!

1

I had a spare Arduino with 32U4 (got it from ebay for $6 with shipping just to try) and relay module (I purchased it for a project that eventually failed).

I decided to use a DC motor from an old VCR, which I control from relay. Of course, stepper would work better. Or at least DC motor with PWM. But indeed, the fact that the target jumps like crazy rather than slides smoothly, is rather cool.

First, I made it with no limit switches. After a few unsuccessful attempts to write a software that returns it to the center (traction with pulley is not perfect), I installed the switches. Fortunately, it is very easy to program Arduino interrupts.

2

Here is one more picture.

3

How do I install it in place? I just place cross bars on a shelf and put a weight on them.

And finally, a video. Enjoy!

Shooting Target Video

And, of course, source codes:

int m1=4;
int m2=5;

long correction = 400; // if we are at the edge, how far do we move back to the center?

long mode=0; // 0 – random, 1 = correct to the right, 2 = correct to the left

void setup() {
pinMode(m1, OUTPUT);
digitalWrite(m1, HIGH);

pinMode(m2, OUTPUT);
digitalWrite(m2, HIGH);

pinMode(2,INPUT);
digitalWrite(2, HIGH); // pullup
pinMode(3,INPUT);
digitalWrite(3, HIGH); // pullup

attachInterrupt(1, int2, FALLING);
attachInterrupt(0, int3, FALLING);
}

void int2(void) {
// stop the motors
digitalWrite(m1, HIGH);
digitalWrite(m2, HIGH);
mode=1; // Request Correction
}

void int3(void) {
// stop the motors
digitalWrite(m1, HIGH);
digitalWrite(m2, HIGH);
mode=2; // Request Correction
}

void loop() {

if (mode == 1)
{
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
delay(correction);
mode=0;
return;
}
else if (mode==2)
{
digitalWrite(m1, LOW);
digitalWrite(m2, HIGH);
delay(correction);
mode=0;
return;
}

long dir = random(4); // 0 and 1 move, the rest – wait.
long how_far = random(150);
how_far+=50; // at least 200ms
if (dir==0)
{
digitalWrite(m1, LOW);
digitalWrite(m2, HIGH);
}
else if (dir==1)
{
digitalWrite(m1, HIGH);
digitalWrite(m2, LOW);
}
else
{
how_far *= 10; // make sleep longer than a move
}
// otherwise don’t move

// keep going
delay(how_far);
// stop
digitalWrite(m1, HIGH);
digitalWrite(m2, HIGH);

}

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>