Arduino Temperature Sensor with buttons
1 view (last 30 days)
Show older comments
I am trying to code buttons to display temp sensor on my arduino board. So, in our project we have two temp sensor and two buttons we have to figure out that when we press one button it would display temperature from one sensor and when we press button 2 it should display temperature from temp sensor 2.
0 Comments
Answers (2)
Jogesh Nanda
on 27 Feb 2019
The solution is simple. In the Arduino declare a variable to pass temperature
double temperature;
Then write a if else condition for switch
if (button 1 == pressed)
temperature = temp 1;
else if (button 2 == pressed)
temperature = temp 2;
end
then send the temperature value to Serial.print.
0 Comments
Madhu Govindarajan
on 27 Feb 2019
If you need your code to be deployed to the Arduino and work independent of PC, then use Simulink Support Package for Arduino. It has different blocks that can help bring in the temperature sensor data (Analog read, I2C Read, SPI) depending on the output type of sensor. Likewise there is a block that reads digital pins to detect button press. You might have to use/create a display block for the specific display module.
If you are looking for code to run on MATLAB while Arduino is connected to PC, then use MATLAB Support Package for Arduino. Use the Getting Started resources on the website to help understand how to bring in sensor data and write sensor data to displays.
Usually I have seen that experts are more willing to help when you have made some progress and ask their help for when you are stuck, as opposed to asking a completely open ended problem.
HTH,
Madhu
0 Comments
See Also
Categories
Find more on Modeling in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!