“RA?” Party Saver

INSPIRATION

The most dreadful thing at a party is when someone knocks on the door. The booming bass abruptly stops and people scramble to hide. Now we need someone to check while others are in their safe spots. To communicate discreetly, we need a visual indicator.

IDEa

When the button is pressed, a conspicuous red exclamation appears. Once the button is released, the bright green question mark comes back. If someone turns on the light, which is very bright compared to the dim party environment, the LED indicators brighten up to signal the message better.

BREADBOARD & ARDUINO BOARD

HERE

DEMO

CODES

bool button = LOW; 
int light = 0; 

void setup() {
  // put your setup code here, to run once:
    pinMode(7, INPUT);
  for (int i = 2; i < 14; i++) {
    pinMode(i, OUTPUT);
  }
  Serial.begin(9600);
}

void loop() {
  // put your main code here, to run repeatedly:
  button = digitalRead(7);
  light = analogRead(A0);

  int mappedLight = map(light, 0, 1023, 0, 255);
  Serial.print("Analog value : ");
  Serial.print(light);
  Serial.print(" Mapped value : ");
  Serial.println(mappedLight);
  
  if (button == HIGH) {
    for (int i = 2; i < 7; i++) {
      digitalWrite (i, HIGH); //turns on red LED
      analogWrite(i, mappedLight);
    }
    for (int j = 8; j < 14; j++) {
      digitalWrite (j, LOW);        //turns off green LED
    }
  }
  else {
    for (int i = 2; i < 7; i++) {
      digitalWrite (i, LOW);        //turns off red LED
    }
    for (int j = 8; j < 14; j++) {
      digitalWrite (j, HIGH);        //turns on green LED
      analogWrite(j, mappedLight);
    }
  }
}

CHALLENGES

Given the fact that 10 LEDs were used, the breadboard obviously look messy, which made it hard to organize. It was not simple to figure out the mistake in the circuit, but, with patience, it came out alright.

Leave a Reply