File tree Expand file tree Collapse file tree 2 files changed +10
-15
lines changed
examples/ReadSensorOtherUnits Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change 1
1
/*
2
2
MKR THERM Shield - Read Sensors
3
3
4
- This example reads the temperatures (in fahrenheit and kelvin ) measured by the thermocouple
4
+ This example reads the temperatures (in Fahrenheit and kelvins ) measured by the thermocouple
5
5
connected to the MKR THERM shield and prints them to the Serial Monitor
6
6
once a second.
7
7
@@ -33,13 +33,13 @@ void loop() {
33
33
Serial.print (THERM.readReferenceTemperature ());
34
34
Serial.println (" °C" );
35
35
36
- Serial.print (" Temperature in Fahrenheit" );
36
+ Serial.print (" Temperature in Fahrenheit " );
37
37
Serial.print (THERM.readTemperature (FAHRENHEIT));
38
38
Serial.println (" °F" );
39
39
40
- Serial.print (" Temperature in Kelvin" );
40
+ Serial.print (" Temperature in Kelvin " );
41
41
Serial.print (THERM.readTemperature (KELVIN));
42
- Serial.println (" °F " );
42
+ Serial.println (" K " );
43
43
44
44
Serial.println ();
45
45
Original file line number Diff line number Diff line change @@ -96,17 +96,12 @@ float THERMClass::readTemperature(int units)
96
96
// multiply for the LSB value
97
97
celsius = rawword * 0 .25f ;
98
98
99
- if (units=FAHRENHEIT)
100
- {
101
- return (celsius * 9.0 / 5.0 ) + 32.0 ;
102
- }
103
- else if (units=KELVIN)
104
- {
105
- return (celsius + 273.15 );
106
- }
107
- else if (units=CELSIUS)
108
- {
109
- return celsius;
99
+ if (units == FAHRENHEIT) {
100
+ return (celsius * 9.0 / 5.0 ) + 32.0 ;
101
+ } else if (units == KELVIN) {
102
+ return (celsius + 273.15 );
103
+ } else {
104
+ return celsius;
110
105
}
111
106
}
112
107
You can’t perform that action at this time.
0 commit comments