About this deal
void ceaseFire(int selector) { // function to stop firing the gun, based on what firing mode is selected boolean invertInputs; // TRUE turns on internal pull-ups, use if closed switch connects arduino pin to ground
Nerf tank | Arduino Blog A remote-controlled Arduino Nerf tank | Arduino Blog
Continuing work on the project, David plans to power it with LiPo batteries – “It currently runs on 14 (!) AA batteries which really don’t last very long as the drive motors and flywheel motors are pretty greedy.” invertInputs = true; // TRUE turns on internal pull-ups, use if closed switch connects arduino pin to ground
To generate the PWM signal, we need to specify a frequency and duty cycle. The servo expects 20 ms ‘off’ time, so the equations for the frequency and duty cycle are given below, where ‘pulse’ is ‘on’ time. Pulses of 1.5ms turn the motor to 90 degrees; shorter pulses move the servo to 0 degrees and longer pulses move towards 180 degrees. Pulse length is set based on how far off-center the target currently is from the reference point of the aiming system. The camera is mounted on the Nerf gun, and its center is aligned with the barrel. Therefore, we set the change in pulse width to be the difference between the current x and y coordinates of the center of the target face and (160, 120), the center of the frame. We limited the minimum and maximum pulse lengths for each servo to the range we found it could smoothly travel. We also limited the maximum change in pulse width in one time step so that the servo movement would not be too jerky. Change in panning servo's PWM duration depends on # difference between current x position and center
NERF | Toys R Us Canada NERF | Toys R Us Canada
boolean useAmmoCounter = false; // if you want to use the shot counter / clip size feature, set this to true
Computer Vision Design/Testing
In my opinion, a 5 kg spring works best (the original one is a two kilo spring). I tried a 7 kilo spring in one, and although it was strong, it resulted in a lot of mis-firing. During the two months of evenings and weekends he spent working on the project over the summer, several design changes were made. “The biggest disappointment was that the huge chunky motors I had didn’t have enough torque to turn the bot successfully. Getting the right motors is an area where I am definitely still learning and it’s a critical factor to get right in building a successful bot.”