Click here to Skip to main content
15,888,113 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi there, I am working on a little project for college. A part of this little project is by using an Arduino, button, temperature sensor and LCD, I should be able to press a button and then display the temperature on an LCD.

How can I get the LCD to display temperature after pressing a button ?

What I have tried:

I have looked at tutorials which explain how to get an LCD to display temperature using a temperature sensor with no button involved and have looked at other arduino projects which use buttons, to see how to combine them to do what I need them to do which I have mentioned already but have had no luck at all.
Posted
Updated 16-Jan-19 16:00pm
Comments
[no name] 16-Jan-19 10:43am    
a.) Detect button pressed
b.) Read in Sensor value
c.) Calculate temp=f(sensor)
d.) Write the result to LCD
Member 14082063 16-Jan-19 10:48am    
Thank you for your response, to clarify on arduino sketch, in the code it first has to detect a button has been pressed and then read in the sensor value.

Calculate temp=f(sensor) and write to lcd should be fine as there are example codes online
[no name] 16-Jan-19 10:54am    
Display Temperature on LCD : 3 Steps[^] and implement the button pressed
Member 14082063 16-Jan-19 11:00am    
Thank you once again, the link you sent is to site explains how to get a lcd to display temperature. To be able to press a button in order to display the temp on a lcd. Would the following:


int ledPin = 13; // choose the pin for the LED
int inPin = 7; // choose the input pin (for a pushbutton)
int val = 0; // variable for reading the pin status

void setup() {
pinMode(ledPin, OUTPUT); // declare LED as output
pinMode(inPin, INPUT); // declare pushbutton as input
}

void loop(){
val = digitalRead(inPin); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(ledPin, LOW); // turn LED OFF
} else {
digitalWrite(ledPin, HIGH); // turn LED ON
}
}

Then replace the led with the temperature sensor ?

Lots of samples at Gallery of Things | Tinkercad[^].
 
Share this answer
 
Comments
Member 14082063 16-Jan-19 11:26am    
Thank you, I will definitely check it out
[no name] 16-Jan-19 11:30am    
He he, cool link. 5
There's a project like what you are trying to do, plus others, here: SparkFun
Inventor’s Kit
[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900