Unusual Switch – Jade

 

Description

In this project, I used LEDs to create a switch that doesn’t require the need of my hands. The mechanism is that if you move close enough to each other, the red light will turn on and the green light goes out. Otherwise, the green light is on.

The idea of this project is inspired by social distance. If you are keeping a distance with other person, the green light is on, so normally it keeps on. If you are too close, red light is on, suggesting that you violate the social distance. I used masks to protect our arms and also as a symbol.

 

Code

const int LED2 = 2;
const int LED = 3;
int state = HIGH;

void setup() {
  // put your setup code here, to run once:
  pinMode(LED2, OUTPUT);
  pinMode(LED, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  digitalWrite(LED, LOW);
  digitalWrite(LED2, state);
  if (digitalRead(LED) == HIGH) {
    state = LOW;
  } else {
    state = HIGH;
  }
}

 

Process

I connect the LEDs to pins 2, 3. I read input from the red one and output the green light. On the circuit of red LED, I connected another two cables which make the switch. When the two cables meet, the circuit will be closed, and the red light turns on, so the green light goes off. Because in my code, I set it so that when the red light is on, the green light will change state.

The challenge I encounter is to figure out a creative way to make a switch free of the use of hands. Initially, I also thought of several ideas, but they required indirect use of hands. So it took me sometime to think of which part of my body I want to use for the switch.

Though, it was interesting to work on circuits, cables and codes!

Leave a Reply