We created a rubber band sentry gun which can rotate to aim, and adjusts the rubber band launch angle. It includes two DC motors for lift and spin, and a solenoid which releases the rubber band.

See a test run of the sentry gun:

Here is a quick run through of the controls:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
// Define the pin numbers on which the outputs are generated.
#define MOT_A1_PIN 5
#define MOT_A2_PIN 6
#define MOT_B1_PIN 9
#define MOT_B2_PIN 10
#define Spin A0
#define Lift A1
#define fire 3
 
int to_fire = 7;
long check = 0;
long time_fired = 0;
 
bool not_print = true;
bool not_fire = true;
// ================================================================================
/// Configure the hardware once after booting up.  This runs once after pressing
//// reset or powering up the board.
void setup(void)
{
  // Initialize the stepper driver control pins to output drive mode.
  pinMode(MOT_A1_PIN, OUTPUT);
  pinMode(MOT_A2_PIN, OUTPUT);
  pinMode(MOT_B1_PIN, OUTPUT);
  pinMode(MOT_B2_PIN, OUTPUT);
  pinMode(Spin, INPUT);
  pinMode(Lift, INPUT);
  pinMode(fire, INPUT);
  pinMode(to_fire, OUTPUT);
  digitalWrite(to_fire, LOW);
 
  // Start with drivers off, motors coasting.
  digitalWrite(MOT_A1_PIN, LOW);
  digitalWrite(MOT_A2_PIN, LOW);
  digitalWrite(MOT_B1_PIN, LOW);
  digitalWrite(MOT_B2_PIN, LOW);
 
  // Initialize the serial UART at 9600 bits per second.
  Serial.begin(9600);
}
 
// ================================================================================
/// Set the current on a motor channel using PWM and directional logic.
/// Changing the current will affect the motor speed, but please note this is
/// not a calibrated speed control.  This function will configure the pin output
/// state and return.
///
/// \param pwm    PWM duty cycle ranging from -255 full reverse to 255 full forward
/// \param IN1_PIN  pin number xIN1 for the given channel
/// \param IN2_PIN  pin number xIN2 for the given channel
 
void set_motor_pwm(int pwm, int IN1_PIN, int IN2_PIN)
{
  if (pwm < 0) {  // reverse speeds
    analogWrite(IN1_PIN, -pwm);
    digitalWrite(IN2_PIN, LOW);
 
  } else { // stop or forward
    digitalWrite(IN1_PIN, LOW);
    analogWrite(IN2_PIN, pwm);
 
  }
}
// ================================================================================
/// Set the current on both motors.
///
/// \param pwm_A  motor A PWM, -255 to 255
/// \param pwm_B  motor B PWM, -255 to 255
 
void set_motor_currents(int pwm_A, int pwm_B)
{
 
  set_motor_pwm(pwm_A, MOT_A1_PIN, MOT_A2_PIN);
  set_motor_pwm(pwm_B, MOT_B1_PIN, MOT_B2_PIN);
 
}
 
 
 
void loop(void)
{
  int spinMotor = analogRead(Spin);
  int liftMotor = analogRead(Lift);
 
 
 
  if(digitalRead(fire)){
    if(not_fire){
      not_fire = false;
      digitalWrite(to_fire, HIGH);
      check = millis();
      time_fired = millis();
      Serial.println("Fire");
    }
  }
   
  if(millis() - time_fired > 1000){
    if(!not_fire and not_print){
      not_print = false;
      Serial.println("Stop Firing");
    }
    digitalWrite(to_fire, LOW);
    time_fired = 0;
  }
 
  if(millis() - check > 3000){
    not_print = true;
    not_fire = true;
  }
 
  spinMotor = constrain(spinMotor, 100, 900);
  liftMotor = constrain(liftMotor, 100, 900);
 
  spinMotor = map(spinMotor, 100, 900, -75, 75);
  liftMotor = map(liftMotor, 100, 900, -255, 255);
 
 
  set_motor_currents(spinMotor, liftMotor);
}