A project with UNO, 1602 LCD and a few push buttons

Hey I need a little here on a project, I have watched a lot of tutorials/videos but what I am trying to do is a bit different, not too hard but as I am a beginner I am unable to find a solution, hope someone can help.
Now what I am trying to do is to build a status LCD Board for the visitors that visits my office, actually it will be a box fitted with an arduino uni=o, a 1602 LCD and Four Status LEDs(one of them would be for power indication).
This box will be fixed to the door with a 5V supply inside, there would be 4-6 wires(as necessary) coming out of the box on the door coming to my desk where I would have another box with 3 push buttons and a power button to turn my arduino on/off.

The first Line of the 1602 will always Display "* Haris' Office *" which is pretty simple.

The second line is where things get complicated and out of my hand.
1st Push Button will instantaneously display "Kindly visit again" and turn Red LED ON.
2nd Push Button will instantaneously display "Meeting in progress; press CALL button if urgent" and turn Yellow LED ON.
3rd Push Button will instantaneously display "AVAILABLE: You May Come IN" and turn Green LED ON.

Due to the size of LCD it might be necessary to slide the text from right to left.
If anyone can help me with the program I would be greatly helpful.

This is a project that is quite simple for Arduino.

However most members expect an attempt to be made and then come in and help with any problems.

Start by writing a simple program to read the switches. Then write a program to put messages on the LCD.

Do small changes and save the previous version so you can go back and start again.

Please put your code in its own window as seen in other posts. This can be done by placing     [code]  and [/code]  around the code or use the </> icon. This makes it easier for others to read.

How to use this forum

Weedpharma

thanks weedpharma for your reply, the main problem I am facking is how to get input from the push buttons and then use those inputs in if statements to display on a LCD, please kindly share a tutorial because I dont have a prior experience and I simply dont know where to start from..... :frowning:

I suggest that your read digitalRead for a starter. Next read if and if / else. For the LEDs, read digitalWrite.

I suggest that you make use of (the internal) pull-up resistors of the microcontroller and connect the button between pin and ground. Your biggest challenge will probably be the distance from the Arduino to your desk.

Below is a short code that can get you started (using serial communication). Expand on it and if something is not clear / or does not work, ask.

// when the button is pressed, the signal is low
#define PRESSED LOW

// three buttons (on pins 4, 5 and 6)
const byte btnAvaliable = 4;
const byte btnMeeting = 5;
const byte btnAgain = 6;

void setup()
{
  // setup serial communication
  Serial.begin(9600);

  // buttons make use of internal pullup
  pinMode(btnAvailable, INPUT_PULLUP);
  pinMode(btnMeeting, INPUT_PULLUP);
  pinMode(btnAgain, INPUT_PULLUP);
}

void loop()
{
  byte btnState;

  btnState = digitalRead(btnAvailable);
  if(btnState == PRESSED)
  {
    Serial.println(F("AVAILABLE: You May Come IN");
  }
}

If you can get it working via serial as opposed to wired buttons, you could get a couple of cheap HC-05 bluetooth modules and a mini or micro and build a wireless remote. You could also use one HC-05 module on the UNO, and control it via your laptop or smartphone with a simple app you can download for free.

Hi everyone, I have finally come up with a prototype and its working!
I am having a small trouble I wish someone could help me with it I would be much obliged!
Actually I am controlling a 1602 LCD and 3 LEDs from an IR Remote its a cheap one for arduino paired with a 1738 TSOP. The problem is that when a change the status of the LED from the remote it changes but it changes back to the default state after a few seconds, sometimes it happens sometimes it doesnt. I would like help on how I can store the input coming through the TSOP so that even after removing the Tsop the LED doesnt return to its default state but the last state... I am attaching the Code I am using..

sketch_may27a.ino (2.39 KB)

Please post the code in code tags so we can just read it online.

Your results might contain garbage when the result of irrrecv.decode returns false. Even if the function returns false, you still use it.

I have no experience with IR but this would be the first change (based on how I understand your code); this might solve your problem.

void loop() {
  // if no signal received
  if (!irrecv.decode(&results))
  {
    // nothing to do
    return;
  }

  irrecv.resume(); // receive the next value

  ...
  ...

If no IR signal is received the rest of loop is simply skipped.

Next change would be to use the pin names. Why do you e.g. have a variable PWRLED but don't use it in the digitalWrite.

#include <LiquidCrystal.h>
#include "IRremote.h"
 
int receiver = 10;

/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'
 
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int PWRLED = 6;
int GLED = 7;
int YLED = 8;
int RLED = 9;

void setup() {
  pinMode(PWRLED, OUTPUT);
  pinMode(GLED, OUTPUT);
  pinMode(YLED, OUTPUT);
  pinMode(RLED, OUTPUT);
  irrecv.enableIRIn(); // Start the receiver
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("Haris' Office    ");

}

void loop() {
  if (irrecv.decode(&results)) // have we received an IR signal?
 
    {
      irrecv.resume(); // receive the next value
    }  

  digitalWrite(6, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(50);              // wait for a second
  digitalWrite(6, LOW);    // turn the LED off by making the voltage LOW
  delay(350);  
  
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:

  if(results.value == 0xFFB04F ){
       lcd.print("Busy, Ring!     "); 
       digitalWrite(9, HIGH);
       digitalWrite(8, LOW);
       digitalWrite(7, LOW);}
    else if(results.value == 0xFF7A85){
       lcd.print("Busy, Ring!     "); 
       digitalWrite(9, HIGH);
       digitalWrite(8, LOW);
       digitalWrite(7, LOW);}   
    else if(results.value == 0xFF5AA5){
       lcd.print("Busy, Ring!     "); 
       digitalWrite(9, HIGH);
       digitalWrite(8, LOW);
       digitalWrite(7, LOW);}  
    else if(results.value == 0xFF6897){
       lcd.print("Available       ");
       digitalWrite(7, HIGH);
       digitalWrite(9, LOW);
       digitalWrite(8, LOW);}
    else if(results.value == 0xFF9867){
       lcd.print("Come back again!");
       digitalWrite(8, HIGH);
       digitalWrite(9, LOW);
       digitalWrite(7, LOW);}
    else if(results.value == 0xFF18E7){
       lcd.print("Come back again!");
       digitalWrite(8, HIGH);
       digitalWrite(9, LOW);
       digitalWrite(7, LOW);}
    else if(results.value == 0xFF38C7){
       lcd.print("Come back again!");
       digitalWrite(8, HIGH);
       digitalWrite(9, LOW);
       digitalWrite(7, LOW);}
    else{
       lcd.print("Available       ");
       digitalWrite(7, HIGH);
       digitalWrite(9, LOW);
       digitalWrite(8, LOW);
       }
}

Reference Program:

#include "IRremote.h"
 
int receiver = 11; // Signal Pin of IR receiver to Arduino Digital Pin 11
 
/*-----( Declare objects )-----*/
IRrecv irrecv(receiver);     // create instance of 'irrecv'
decode_results results;      // create instance of 'decode_results'
 
void setup()   /*----( SETUP: RUNS ONCE )----*/
{
  Serial.begin(9600);
  Serial.println("IR Receiver Button Decode"); 
  irrecv.enableIRIn(); // Start the receiver
 
}/*--(end setup )---*/
 
 
void loop()   /*----( LOOP: RUNS CONSTANTLY )----*/
{
  if (irrecv.decode(&results)) // have we received an IR signal?
 
  {
    translateIR(); 
    irrecv.resume(); // receive the next value
  }  
}/* --(end main loop )-- */
 
/*-----( Function )-----*/
void translateIR() // takes action based on IR code received
 
// describing Remote IR codes 
 
{
 
  switch(results.value)
 
  {
 
  case 0xFF629D: Serial.println(" FORWARD"); break;
  case 0xFF22DD: Serial.println(" LEFT");    break;
  case 0xFF02FD: Serial.println(" -OK-");    break;
  case 0xFFC23D: Serial.println(" RIGHT");   break;
  case 0xFFA857: Serial.println(" REVERSE"); break;
  case 0xFF6897: Serial.println(" 1");    break;
  case 0xFF9867: Serial.println(" 2");    break;
  case 0xFFB04F: Serial.println(" 3");    break;
  case 0xFF30CF: Serial.println(" 4");    break;
  case 0xFF18E7: Serial.println(" 5");    break;
  case 0xFF7A85: Serial.println(" 6");    break;
  case 0xFF10EF: Serial.println(" 7");    break;
  case 0xFF38C7: Serial.println(" 8");    break;
  case 0xFF5AA5: Serial.println(" 9");    break;
  case 0xFF42BD: Serial.println(" *");    break;
  case 0xFF4AB5: Serial.println(" 0");    break;
  case 0xFF52AD: Serial.println(" #");    break;
  case 0xFFFFFFFF: Serial.println(" REPEAT");break;  
 
  default: 
    Serial.println(" other button   ");
 
  }// End Case
 
  delay(500); // Do not get immediate repeat
 
 
} //END translateIR