For our second deliverable, I decided to try a new design from my first demo. My main goal in mind was having the product sense its surroundings and create a shocking reaction. I came up with the idea of a box. The box would be very still and have a lever arm sticking out of it. I originally imagined it as being like a switch where I’d throw on a sign saying not to flip the switch. Playing off the idea of childhood curiosity and explicitly doing what you’re told not to, the expectation is that you’ll go to flip the switch. Using the photoreceptor, if it senses you are close to touching the switch it will flip itself. It almost gives a fun lifelike defiance to a very simple robot. Every time you reach for the switch, it defiantly flips away. 

I started as early as possible, making CAD files as soon as I thought up the idea. I made the box large enough to keep the project neat and tidy. It left enough space so I could fit the Arduino inside. 

While I thought this would be a fun idea, it definitely would have its challenges. somehow I’d have to wire the photoreceptor onto the lever arm and hope nothing gets unplugged or tangled. I also ended up having many more hardware problems than I anticipated. I couldn’t get the photoreceptor to work, nor any other similar proximity sensors. While this meant many hours of frustration, I actually kept reworking my idea and actually landed on a simpler final product that I liked much more. Instead of running away, the lever arm tried to catch you. Using a photoresistor, the box senses if your finger is over it and swings to try and catch you. I added “spikes” to add to the fear and excitement the game causes. I ended up very happy with the final result. 

I eventually, did not end up putting all the wires inside the box because I wanted to keep my breadboard and didn’t want to risk the long wires being pulled out if they hit the servo. If I could change anything, I would get a proximity sensor working since the photoresists can be triggered by any shadow, not just by coming close to it. My final code was much simpler than the original toggle system I had intended with the fleeing lever. The delays in my if statements make it so that the box does not always respond instantly, adding an extra level of suspense to the game. Overall, it ended in success.

 

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) < 890) {
    analogWrite(servoPin, -90);
      delay(500);
    }
  else {
    analogWrite(servoPin, 90);
    delay(500);
    }
}