Office Status Board

Here is my weekend project.

CODE:

/*
Small Office Message Board     
By: Matthew Eccles
Created  18 OCT 2013
http://www.matteccles.me


 Many times you are on the phone and someone walks up behind you and starts talking to you.
 So with this sign you can avoid this by displaying a small message on your desk.
 It also works as an AFK status message for your co-workers.
     
 Supplies:
   * 1ea Arduino Uno
   * 1ea Seeed Prototype board
   * 1ea 16×2 LCD
   * 1ea Potentiometer
   * 1ea Pushbutton
   * 1ea 10K resistor
   * 3ea 460 resistor
   * 2ea LED 5mm
   * 1ea LED 3mm
   * 1ea 2.54mm header 1×40 
   * 1ea Solder board 2″x4″
   * 1ea Project Enclosure 6″x4″x2″
   
 Other Items:
   * Solder Iron
   * Hot Glue Gun
   * Wires
   
 Wired Up:
   * Arduino Pin 2 to LCD Pin 14
   * Arduino Pin 3 to LCD Pin 13
   * Arduino Pin 4 to LCD Pin 12
   * Arduino Pin 5 to LCD Pin 11
   * Arduino Pin 8 to Pushbutton
   * Arduino Pin 9 to LED (460 Ω Resistor)
   * Arduino Pin 10 to LCD Pin 6
   * Arduino Pin 11 to LCD Pin 5
   * Arduino Pin 12 to LCD Pin 4
   * Arduino Pin 13 to LCD Pin 2   

   * LCD Pin 1 to Ground
   * LCD Pin 2 to Arduino Pin 13 -OR- 5V
   * LCD Pin 3 to Potentiometer
   * LCD Pin 4 Arduino Pin 12
   * LCD Pin 5 Arduino Pin 11
   * LCD Pin 6 Arduino Pin 10
   * LCD Pin 7 N/A
   * LCD Pin 8 N/A
   * LCD Pin 9 N/A
   * LCD Pin 10 N/A
   * LCD Pin 11 Arduino Pin 5 
   * LCD Pin 12 Arduino Pin 4
   * LCD Pin 13 Arduino Pin 3
   * LCD Pin 14 Arduino Pin 2
   * LCD Pin 15 5V
   * LCD Pin 16 to Ground
   
   
   
 */

#include
LiquidCrystal lcd(12, 11, 10, 5, 4, 3, 2);

int backLight = 13; // Arduino pin 13 will control the backlight connected to pin 15 on the LCD
// Please note that I am not using the “backLight” as I have the LCD Pin 15 wired to 5V. 
int buttonPin = 8;  // Arduino pin 8 will sence the pushbutton being pressed
int led9Pin = 9;  // Arduino Pin 9 will control the LED that tells you when the LCD is on an Even display count
int buttonPushCounter = 0;   // This is the counter that counts the number of button presses
int buttonState = 0;         // This is the current state of the button
int lastButtonState = 0;     // This is the previous state of the button

boolean lastButton = LOW;
boolean currentButton = LOW;
boolean lcdChange = false;

long previousMillis9 = 0; // Part of the Clock for the LED9Pin
long randInterval9 = 0;  // Part of the Clock for the LED9Pin
int led9State = LOW; //Sets the state of teh LED9Pin to Low (off)


void setup() {

  pinMode(backLight, OUTPUT); // initialize the LCD backlight as an output
  pinMode(buttonPin, INPUT); //  initialize the button pin as a input
  pinMode(led9Pin, OUTPUT);  // initialize the LED as an output
  Serial.begin(9600);  // initialize serial communication
  lcd.begin(16,2); // columns, rows. use 16,2 for a 16×2 LCD (if you have 16×4, change it to refect it)
  Serial.begin(9600);  // initialize serial communication:
  
}




void loop() {

  unsigned long currentMillis = millis();
  
  buttonState = digitalRead(buttonPin);    // reads the pushbutton input pin
  if (buttonState != lastButtonState) {   // compares the buttonState to its previous state
    if (buttonState == HIGH) {      // if the state has changed, increment the counter
      // if the current state is HIGH then the button went from off to on:
      buttonPushCounter++;
      Serial.println(“on”);
      Serial.print(“number of button pushes:  “);
      Serial.println(buttonPushCounter);
    } 
    else {
      // if the current state is LOW then the button went from on to off:
      Serial.println(“off”); 
    }
  }
   if (buttonPushCounter == 0) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      digitalWrite(led9Pin, LOW);
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(“Matthew Eccles”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1);  // set the cursor to (16,1):
      lcd.print(“>RACHpoint Admin”); // change this text to whatever you like by replacing everything within the quotes. 
         // if you have a 4 row LCD, uncomment these lines to write to the bottom rows and change the “lcd.begin()” statement above.
         //lcd.setCursor(0,2); // sets the cursor to column 0, row 2
         //lcd.print(“Text for Row 3”);
         //lcd.setCursor(0,3); // sets the cursor to column 0, row 3
         //lcd.print(“Text for Row 3”);     
   }
    if (buttonPushCounter == 1) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      digitalWrite(led9Pin, LOW);
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(“PITTSBURGH”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1); // sets the cursor to column 0, row 1
      lcd.print(”     STEELERS”);
   }
    if (buttonPushCounter == 2) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(“ON THE PHONE”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1); // sets the cursor to column 0, row 1
      lcd.print(”     PLEASE WAIT”);
//This next Section can be removed if you don’t need it.  This serves as a reminder that you have a status that you either busy or AFK.
      if(currentMillis – previousMillis9 > randInterval9) {
        randInterval9 = random (100, 1000);
        previousMillis9 = currentMillis;   
      if (led9State == LOW)
        led9State = HIGH;
      else
        led9State = LOW;

    digitalWrite(led9Pin, led9State);}
   }
    if (buttonPushCounter == 3) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(“ON THE PHONE, BE”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1); // sets the cursor to column 0, row 1
      lcd.print(“A FEW MINUTES”);
//This next Section can be removed if you don’t need it.  This serves as a reminder that you have a status that you either busy or AFK.
      if(currentMillis – previousMillis9 > randInterval9) {
        randInterval9 = random (100, 1000);
        previousMillis9 = currentMillis;   
      if (led9State == LOW)
        led9State = HIGH;
      else
        led9State = LOW;

    digitalWrite(led9Pin, led9State);}
   }
    if (buttonPushCounter == 4) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(” GONE TO LUNCH”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1); // sets the cursor to column 0, row 1
      lcd.print(“BE BACK AT 11:30”);
//This next Section can be removed if you don’t need it.  This serves as a reminder that you have a status that you either busy or AFK.
      if(currentMillis – previousMillis9 > randInterval9) {
        randInterval9 = random (100, 1000);
        previousMillis9 = currentMillis;   
      if (led9State == LOW)
        led9State = HIGH;
      else
        led9State = LOW;

    digitalWrite(led9Pin, led9State);}
   }
    if (buttonPushCounter == 5) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(“Away From Desk”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1); // sets the cursor to column 0, row 1
      lcd.print(“Be Back Shortly”);
//This next Section can be removed if you don’t need it.  This serves as a reminder that you have a status that you either busy or AFK.
      if(currentMillis – previousMillis9 > randInterval9) {
        randInterval9 = random (100, 1000);
        previousMillis9 = currentMillis;   
      if (led9State == LOW)
        led9State = HIGH;
      else
        led9State = LOW;

    digitalWrite(led9Pin, led9State);}
   }
    if (buttonPushCounter == 6) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(“Away From Desk”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1); // sets the cursor to column 0, row 1
      lcd.print(“Send Me An Email”);
//This next Section can be removed if you don’t need it.  This serves as a reminder that you have a status that you either busy or AFK.
      if(currentMillis – previousMillis9 > randInterval9) {
        randInterval9 = random (100, 1000);
        previousMillis9 = currentMillis;   
      if (led9State == LOW)
        led9State = HIGH;
      else
        led9State = LOW;

    digitalWrite(led9Pin, led9State);}
   }
    if (buttonPushCounter == 7) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(“In Training”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1); // sets the cursor to column 0, row 1
      lcd.print(“Send Me An Email”);
//This next Section can be removed if you don’t need it.  This serves as a reminder that you have a status that you either busy or AFK.
      if(currentMillis – previousMillis9 > randInterval9) {
        randInterval9 = random (100, 1000);
        previousMillis9 = currentMillis;   
      if (led9State == LOW)
        led9State = HIGH;
      else
        led9State = LOW;

    digitalWrite(led9Pin, led9State);}
   }
    if (buttonPushCounter == 8) {
      digitalWrite(backLight, HIGH); // turn backlight on. Replace ‘HIGH’ with ‘LOW’ to turn it off.
      lcd.clear(); // Start by clearing the screen of the last text.
      lcd.setCursor(0,0); // sets the cursor to column 0, row 0 (the first row)
      lcd.print(“Gov’t Shutdown”); // change this text to whatever you like by replacing everything within the quotes.
      lcd.setCursor(0,1); // sets the cursor to column 0, row 1
      lcd.print(“Furlough Friday!”);
//This next Section can be removed if you don’t need it.  This serves as a reminder that you have a status that you either busy or AFK.
      if(currentMillis – previousMillis9 > randInterval9) {
        randInterval9 = random (10, 100);
        previousMillis9 = currentMillis;   
      if (led9State == LOW)
        led9State = HIGH;
      else
        led9State = LOW;

    digitalWrite(led9Pin, led9State);}
   }
   if (buttonPushCounter >= 9) {
      buttonPushCounter = 0;
}

   lastButtonState = buttonState;    // this saves the current state as the last state, for next time through the loop


 // This delay can be made higher, but the high the number the more time you have to wait to press the button
 // If there is no delay, you will see scree flicker as it clears the screen and loads to the text.
 delay(120); 
}