Gord Payne
Published © GPL3+

Arduino Ping Pong Ball Cannon

Grab a couple of motors, a servo and build a cannon!

IntermediateShowcase (no instructions)12,498
Arduino Ping Pong Ball Cannon

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
13,000 rpm 6V DC motor
×2
7.4V 1300 mAh LiPo Battery
×1
Power MOSFET N-Channel
Power MOSFET N-Channel
60V 10A
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
Any small servo that can run off the Arduino board 5V supply
×1
Resistor 10k ohm
Resistor 10k ohm
×1
1N4007 – High Voltage, High Current Rated Diode
1N4007 – High Voltage, High Current Rated Diode
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

3D Printer (generic)
3D Printer (generic)
Hot glue gun (generic)
Hot glue gun (generic)

Story

Read more

Custom parts and enclosures

Flywheels

Flywheels attached to the motors to fling the balls

Schematics

Cannon Circuit

Code

Ping Pong Ball Cannon

Processing
Arduino Code to control Ping Pong Ball Cannon
/*
 * Ping Pong Ball Cannon
 * 2019 - Gord Payne
 * 
 */
 #include <Servo.h>

Servo servo;

int motorPin = 6; // flywheel motors
int servoPin = 8; // autofeeder servo
int potPin = A0; // potentiometer for speed adjustment
int potVal;
int speedVal; // scaled speed value for motor (potVal/4);
char theVal;

void setup() {
  Serial.begin(9600);
  pinMode(motorPin, OUTPUT);
  pinMode(potPin, INPUT);

}

void loop() {
  potVal = analogRead(potPin);
  speedVal = map(potVal / 4, 0, 255, 80, 220); // you can adjust as appropriate for your setup
  Serial.print(speedVal);
  if (Serial.available() > 0) {
    theVal = Serial.read();


  }
  switch (theVal) {
    case '1': // If '1' was received
      analogWrite(motorPin, speedVal); // turn the motor ON
      delay(2000);
      feedBall(); // feed a ball into the flywheels
      digitalWrite(motorPin,LOW);
      break;
    case '0': // If '0' was received
      digitalWrite(motorPin, LOW); // turn the motor OFF
      break;
    default:
      break;

  }

}

void feedBall(){
  servo.attach(servoPin);
      delay(20);
      servo.write(10);
      delay(400);
     for (int i = 0; i <= 110; i++) { // push the ball into the flywheels
      servo.write(i);
      delay(5);
      }
      delay(100);
     for (int i = 110; i >= 0; i--) { // retract the feeder for the next ball
      servo.write(i);
      delay(5);
      }
      servo.detach();
}

Credits

Gord Payne

Gord Payne

1 project • 2 followers
High school Computer Science teacher in Newmarket, Ontario Canada. Arduino is better than AIR!

Comments