For my input-output project, I wanted to create a closed-loop that functions independently and continuously. I thought that it would be fun to have a box and a kicking mechanism that kicked the ball around the box. I wanted to make it kick forever by having the box on a tilt such that the ball would always roll back to where it would be kicked and the variety would come from the rounded kicking face hitting at different angles.

How it works:

The corner that the ball rolls into has a photo resistive sensor built into it so that as soon as the ball is in position, the arm attached to a servo can swing into the slot. The only problem I had was that the arm had a warp, which made it sometimes get caught on the slot. I replaced it with a straw cut to emulate the kicker’s shape.

Below you will find the Arduino code as well as a zip file containing all of the Solidworks materials.

#include <Servo.h&gt;

const int led = 4;
const int pr = 2;
const int pause = 250;

Servo swervo;
void setup() {
  swervo.attach(3);
  pinMode(pr,INPUT);
  pinMode(led,OUTPUT);
  
}

void light(){
  digitalWrite(led,HIGH);
  delay(pause);
  digitalWrite(led,LOW);
}


void detectnhit(){
  if (digitalRead(pr) == LOW){
    light();
    swervo.write(53);
    delay(pause);
    swervo.write(40);
    
  }
  else{
    swervo.write(40);
  }
  
}

void loop() {
  detectnhit();
}