Egress Code Hat

The egress hat allows one to walk around a building to ensure that there is adequate light on the floor for emergency egress (5 footcandles in most municipalities). The LDR sensor is on the top of the hat to ensure nothing blocks it, and the red LED is under the brim, easiliy visible to the wearer, indicating that the area is not in complience

 

Code:

int int LDR = 2;    // select the input pin for the potentiometer
int ledPin = 13;   // select the pin for the LED
int val = 0;       // variable to store the value coming from the sensor

void setup() {
  pinMode(ledPin, OUTPUT);  // declare the ledPin as an OUTPUT
}

void loop() {
  val = analogRead(LDR);    // read the value from the sensor
 if (val >= 500) {         // check if the input is HIGH (button released)
  digitalWrite(ledPin, HIGH);   // sets the LED on
  delay(500);                  // waits for a second
  digitalWrite(ledPin, LOW);    // sets the LED off
  delay(500);                  // waits for a second

  } else {
    digitalWrite(ledPin, HIGH);  // turn LED ON
  }
           
}

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s