Week 8: Unusual Switch

For this week’s task, I created a switch which can be activated by touching a piece of wire taped on top of my foot to an aluminum foil sheet taped on the bottom side of a chair, emulating a self-defense move. When the switch is activated, a servo starts moving two aluminum foil pieces back and forth towards an aluminum foil figure , emulating slapping a stickman.

Process:

I started with designing the figure and securely taping everything to the cardboard. That was the most difficult part. After figuring out that part, arranging the circuit was straightforward. Below are a few pictures detailing the process and a video demo of the switch:

Unusual Switch

My Arduino code is very short. It controls the motion of the servo, allowing for a short pause in between.

#include <Servo.h>

Servo servo;
const int servoPin = 2;
int currmillis = 0;
bool dir = 0;

void setup() {
  servo.attach(servoPin);
}

void loop() {

  if ((int)millis() - currmillis >= 1000) {
    currmillis = millis();
    dir = !dir;
  }

  if (dir) {
    servo.write(180);
  } else {
    servo.write(0);
  }

}

 

Leave a Reply