Our Catch Machine!

We decided to make a catch machine from our knowledge of the Demo 2 project. We started by using the Servos and a Ball and a Track. The track is kept relatively simple to make sure the Servos have enough power to catch and push back the ball.

We used photo-resistors to check the shadow of the ball to make sure the Servos knew when to “throw” the ball back. The act of triggering the resistors involved changing the intensity of the surrounding lights in the Physical Computing Lab to make sure both sides of the track were receiving similar light quantities. The photo-resistors themselves acted as a make shift speed bump to make sure the ball didn’t just hit the arm and bounce out of the range of it.
int servoPin = 9;
int sensorPin = A0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(servoPin, OUTPUT);
  pinMode(sensorPin, INPUT);
  analogWrite(servoPin, 90);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(analogRead(sensorPin));
  delay(5);
  if (analogRead(sensorPin) < 775) {
    delay(1000);
    analogWrite(servoPin, 90);
    delay(500);
    analogWrite(servoPin, -90);
    }
    
  else {
    }
}

This is the code that we used to allow the photo-resistors to work in harmony.

int servoPin = 9;
int sensorPin = A0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  pinMode(servoPin, OUTPUT);
  pinMode(sensorPin, INPUT);
  analogWrite(servoPin, 90);

}

void loop() {
  // put your main code here, to run repeatedly:
  Serial.println(analogRead(sensorPin));
  delay(5);
  if (analogRead(sensorPin) < 500) {
    delay(1000);
    analogWrite(servoPin, 90);
    delay(500);
    analogWrite(servoPin, -90);
    delay(1000);
    analogWrite(servoPin, -130);
    delay(500);
    analogWrite(servoPin, -90);
    }
    
  else {
    }

This is the updated code after the feedback to get a wave from the previous thrower.