Pages: [1]   Go Down
Author Topic: Push a Button to Display Text on a LCD ?  (Read 1584 times)
0 Members and 1 Guest are viewing this topic.
New Zealand
Offline Offline
Full Member
***
Karma: 1
Posts: 105
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

 smiley-eek smiley-roll smiley-roll How do i make this work if i have a Push Button on a analog port and push it and want a message to Display Text on a LCD ?
or using a pot from 0 to 100 % at 50% turn on a message on the lcd and if the pot gose below 50% the message turns off.?
im new to all this so any help would be great smiley-surprise
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4326
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you looked into the lcd.display() and lcd.nodisplay() commands?  You would send your text to the display and immediately turn it off.  Then later, when you sense the push button or potentiometer position, you could turn it on or off as you desire.

Don
Logged

New Zealand
Offline Offline
Full Member
***
Karma: 1
Posts: 105
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes but im still not 100% sure on what code i need for this i have been working on this for ages with no luck.


* Image0532.jpg (129.92 KB, 560x420 - viewed 55 times.)
« Last Edit: February 10, 2012, 03:47:53 pm by vmansmx5 » Logged

New Zealand
Offline Offline
Full Member
***
Karma: 1
Posts: 105
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Well i came up with this still its not what im affter this using 2 buttons to change { on } { off } message
i want to do this with just one button.?
Also has temp reading from input 0.
how do i change the message if the temp go over a set point?

#include <LiquidCrystal.h>

LiquidCrystal lcd(12, 11, 10, 9, 8, 7);

int SENSOR = 0;
float D = 0;
float T = 0;

void setup()
{
  lcd.begin(20, 4);
 
  attachInterrupt(0, ON, HIGH);
  attachInterrupt(1, OFF, HIGH);
}

void loop()
{
  lcd.setCursor(0,0);
  lcd.print("FAN");
  lcd.setCursor(0,1);
  lcd.print("MONITOR");
  delay(1000);

  lcd.setCursor(5, 3);
  D = analogRead(SENSOR);
  T = (D * 4.81 * 100)/1023;
 
  Serial.print(T);
  Serial.println("C");
 
  lcd.print(T);
  lcd.print("C");
}

void ON()
{
  lcd.setCursor(8,0);
  lcd.print("ON ");
}
   
void OFF()
{
  lcd.setCursor(8,0);
  lcd.print("OFF");
}
   
Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4326
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
turn on a message on the lcd and if the pot gose below 50% the message turns off

I guess you have me confused.  I thought you wanted to turn the display on and off but your code displays the words "ON" and "OFF".

How about:

Code:
void ON()
{
  lcd.display();
}
  
void OFF()
{
lcd.nodisplay();
}

Note:  When posting code you should highlight that code and use the 'code' button (the one with the '#' symbol).

To do this with one button you would use one interrupt and have the interrupt code toggle between which of the two functions it invokes.


Don
« Last Edit: February 11, 2012, 06:00:01 pm by floresta » Logged

Western New York, USA
Offline Offline
Faraday Member
**
Karma: 36
Posts: 4326
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

With respect to your photo - it's not too clear how the displays are wired, but have you seen this?  Make sure you scroll down to the photos.

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1265969050


Don
Logged

New Zealand
Offline Offline
Full Member
***
Karma: 1
Posts: 105
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Here are some better photos from my phone not the best.
well yes i do want to use just one button that was just a test realy. thats one part im trying to do.
also i want another message to come on when a pot gose over a set point like  ( To High ) message and ( To Low ) ?
how would i have the code to toggle between the interrupt code.

Code:
#include <LiquidCrystal.h> // include the LCD library
LiquidCrystal lcd(12, 11, 6, 5, 4, 3);
LiquidCrystal lcd2(12, 10, 6, 5, 4, 3);

Thats how i have the 2x 20.4 LCDs working and to works great


* Image0534.jpg (94.57 KB, 640x480 - viewed 28 times.)

* Image0536.jpg (144.87 KB, 640x480 - viewed 44 times.)
« Last Edit: February 11, 2012, 04:47:44 pm by vmansmx5 » Logged

Pages: [1]   Go Up
Jump to: