Arduino Temperature Sensor with buttons
1 回表示 (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (2 件)
Jogesh Nanda
2019 年 2 月 27 日
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 件のコメント
Madhu Govindarajan
2019 年 2 月 27 日
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 件のコメント
参考
カテゴリ
Help Center および File Exchange で Modeling についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!