Ideation

After discussing for some time, we decided to make two machines that ‘picked on’ one another. Similar to friends joking around, one machine would move and trigger the other, which then would respond by doing the same thing. Our results resemble children bothering each other in a playful way.

Design

By attaching servos to a shape similar to what Jai had for his Demo 2, we created two bodies with movable arms triggered by photoresistors. As one arm comes down, it casts a shadow on the other robot’s photoresistor; the shadowed robot then responds by moving its own arm, repeating the process.

Solidworks:

Result

After finished, we recorded this video:

As one pokes the other, the other pokes back.

Code

The code for this project is simple, it detects if an input voltage gets above a certain threshold (which means the photoresistor is covered) and then proceeds to move the arm.

#include<Servo.h&gt;

const int photo_pin = A5;
const int servo_pin = 7;
const int swing_angle = 70;
const int reset_angle = 10;
const int light_threshold = 160;

Servo hammer_arm;

void setup() {
  // setup code:
  pinMode(photo_pin, INPUT);
  hammer_arm.attach(servo_pin);
}

void loop() {
  // repeated code:
  int light = analogRead(photo_pin);

  // light &gt; threshold means the resistor is covered 
  if (light &gt; light_threshold){
    delay(800); // allow the other arm to return
    hammer_arm.write(swing_angle);
    delay(800);
    hammer_arm.write(reset_angle);
    delay(800);
  }
}

Final Considerations

While the results were fairly similar to what we expected, our original idea included another level of motion. Each body also has a second servo attached to its base, so that the machine could tilt when ‘bothered’. As we worked through our project, however, we did not find a meaningful way of implementing this movement.