-->

HOW TO GET RID OF ZERO BEHIND COMA ARDUINO


How to Get Rid of Zero Behind the Arduino Comma; When we display temperature and humidity using the DHT library, we find two zeros behind the comma. This number remains zero even though temperature and humidity keep changing. So you could say two zeros behind the comma are just accessories. It would be better if the two zeros behind the comma were removed.

Let's discuss the display first when using a serial monitor. We use an example program on Arduino. We open File → Examples → DHT sensor library → DHTtester. Upload the sample file then open the serial monitor, it will show the results of humidity, temperature there are two zeros behind the comma.







If we display these results using LCD, we will also get two zeros behind the comma as shown below.


The two zeros can be removed by changing the temperature and humidity values ​​to an integer form first then a new integer value is displayed. The way is this:
Before the void setup we initialize the temp for temperature and kelb for humidity.


From here the temp and kelb values ​​are integers (integers). Then we enter the value t to temp and the value h to kelb in the void loop. After that, the value of the temp and kelb values ​​we display.


After we change then we try to upload the program and we see the results on the serial monitor. Then two zeros behind the comma will disappear along with the comma.


If it is displayed on the LCD, the result will be as shown below:


Thus this short article ends and hope it could be helpful.

"Never insult someone's past. Because we don't know what the future is"

Tidak ada komentar:

Posting Komentar

Tulis komentar dengan bijak tanpa unsur SARA, Politik, dan Pornografi.

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel