Borrar filtros
Borrar filtros

Arduino Temperature Sensor with buttons

5 visualizaciones (últimos 30 días)
Abhi Mistry
Abhi Mistry el 25 de Feb. de 2019
Respondida: Madhu Govindarajan el 27 de Feb. de 2019
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.

Respuestas (2)

Jogesh Nanda
Jogesh Nanda el 27 de Feb. de 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;
then send the temperature value to Serial.print.

Madhu Govindarajan
Madhu Govindarajan el 27 de Feb. de 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.


Más información sobre Modeling en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by