For our second Arduino project, we were tasked with creating a new kind of input not covered in class. For my project I wanted to use this task to solve a problem I constantly have with my roommates at our apartment. Since we all are in our rooms most of the time its hard to know who is in the apartment. Therefore, my solution was to create a gravity input along with a key hanger. When one of the roommates gets home, he/she can hang his/her keys in the hanger and a light will turn on letting the other roommates know who is home. This is the final setup without the enclosure:

This idea was inspired by Harry Potter's Magic Clock. This are some picture of the process. One of the main challenges was to create the lever that would create the gravity input. At first, I started looking into springs to create a lever that would close the circuit.


However, I quickly noticed that the springs I had available were too strong for the keys to pull the lever down. To solve this, I made a different kind of lever based on a weight. This is a close up of the lever system:

After figuring out the lever system, the code is fairly simple:

const int buttonPin = 2;  
const int ledPin =  13;

int buttonState = 0;       

void setup() {
  // initialize the LED pin as an output:
  pinMode(ledPin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(buttonPin, INPUT);

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (buttonState == HIGH) {
    // turn LED on:
    digitalWrite(ledPin, LOW);
  } else {
    // turn LED off:
    digitalWrite(ledPin, HIGH);

This are some more pictures of the project:


This is the final project with an enclosure: