Go Down

Topic: lcd(2x16)+10 push buttons+ arduino mega programming (Read 183 times) previous topic - next topic

Oct 28, 2014, 06:24 am Last Edit: Oct 28, 2014, 06:25 am by Mohammed_Azeez
hello

Need Help in programming Arduino Mega with 10 Bush buttons numbered from 1 to 10 and Screen LCD 2x16
When you press any push button appears its number on the screen with a beep sound
When you press on the more than bush button appears there numbers on the screen according to the sequence of pressed
There another bush button when pressed clears the screen and stop the beep sound
I want code to do that
thanks

filk

assuming you have run out of pins to connect single buttons to you want to look at multiple buttons attached to a single pin..

look here for ideas 5 buttons on 1 pin

floresta

hello

Need Help in programming Arduino Mega with 10 Bush buttons numbered from 1 to 10 and Screen LCD 2x16
When you press any push button appears its number on the screen with a beep sound
When you press on the more than bush button appears there numbers on the screen according to the sequence of pressed
There another bush button when pressed clears the screen and stop the beep sound
I want code to do that
thanks

It would be easier for us to do your homework for you if you provided us with the original assignment sheet rather than a paraphrased version.

Don

filk thank you for help.
floresta This is not homework, but is part of a project in the hospital (the nurse call device)..thanks


floresta

Sorry about that but we get a lot of requests to do homework here.

The system proposed in the previous link (reply #1) will not be satisfactory since it cannot deal with simultaneous button presses.

Are you modifying/enhancing an existing call button system or are you creating an entirely new system?

What are the distances involved?

From my hospital experience I don't think a beep will attract any attention.  You need a device that is quiet and annoying, perhaps something along the lines of a seat cushion that can deliver a shock.

I assume that you have read the disclaimer about using an Arduino in safety-critical applications.

Don

 The program code is completed and remained one issue where I need your help,
It is when you press any push button switch  more than once will be repeated appearance switch number on the screen.
I want to show switch number  Once even that was compressed more than once.
Thanks
this sample of the
 code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int Buzerpin = 13;  //buzzer     
const int  buttonPin = 6;
const int  buttonPin2 = 7;
const int  buttonPin3 = 8;
const int  buttonPin4 = 9;
int buttonState = 0;   
int buttonState2 = 0; 
int buttonState3 = 0; 
int buttonState4 = 0;
int lastButtonState = 0;
int lastButtonState2 = 0;
int lastButtonState3 = 0;
int lastButtonState4 = 0;
void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(20, 4);
 lcd.print("SAMAWA HOSPITAL");
 delay(5000);
 lcd.clear();
 pinMode(buttonPin, INPUT);
 pinMode(buttonPin2, INPUT);
 pinMode(buttonPin3, INPUT);
 pinMode(buttonPin4, INPUT);
 pinMode(Buzerpin, OUTPUT);
 Serial.begin(9600);
}
void loop() {
  lcd.noDisplay();
  delay(500);
   // Turn on the display:
  lcd.display();
  delay(500);
 
  buttonState = digitalRead(buttonPin);

  if (buttonState != lastButtonState) {
   
    if (buttonState == HIGH) {
      digitalWrite(Buzerpin, HIGH);
       
  lcd.print("R1");
 
    }
       
  }
 
  lastButtonState = buttonState;
 
 
   
  buttonState2 = digitalRead(buttonPin2);

  if (buttonState2 != lastButtonState2) {
   
    if (buttonState2 == HIGH) {
      digitalWrite(Buzerpin, HIGH);
       // Print a message to the LCD.
  lcd.print("R2");
  lcd.display();
    }
   
  }
 
  lastButtonState2 = buttonState2;
 
 
   
  buttonState3 = digitalRead(buttonPin3);

  if (buttonState3 != lastButtonState3) {
   
    if (buttonState3 == HIGH) {
      digitalWrite(Buzerpin, HIGH);
       
  lcd.print("R3");
  lcd.display();
    }
   
  }
 
  lastButtonState3 = buttonState3;
 
   buttonState4 = digitalRead(buttonPin4);

  if (buttonState4 != lastButtonState4) {
   
    if (buttonState4 == HIGH) {
      digitalWrite(Buzerpin, LOW);
     
  lcd.clear();
    }
   
  }
 
}
   
 

MAS3

Hi.


Please use code tags when posting code.
You can learn how to do that by reading the instructions on how to use the forum, which is available on top of any forum here.

It's not real difficult to have a number appearing only once.
If the number is displayed the first time, set a flag telling that it is already there.
If you are going to display the number, check that flag to see if it isn't already displayed.

The reset button could reset any flags, but you need to figure out if that is what you want.
Do you want to reset 3 calls, when handling the first call ?

Have a look at "blink without delay".
Did you connect the grounds ?
Je kunt hier ook in het Nederlands terecht: http://arduino.cc/forum/index.php/board,77.0.html

Go Up