Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Grove_LCD_RGB_Backlight Grove_temperature PixelArray Servo WS2812
Fork of Wio_3G_example by
Diff: main.cpp
- Revision:
- 72:aa14c091f860
- Parent:
- 71:7d17edde2e03
- Child:
- 73:d47320bcc568
--- a/main.cpp Fri Aug 03 06:46:00 2018 +0000
+++ b/main.cpp Mon Aug 06 09:28:20 2018 +0000
@@ -1,5 +1,6 @@
#include "mbed.h"
#include "Grove_LCD_RGB_Backlight.h"
+#include "Grove_temperature.h"
#define D20 (PB_4)
#define D19 (PB_3)
@@ -9,25 +10,10 @@
AnalogIn ain(A6);
InterruptIn btn(D20);
Grove_LCD_RGB_Backlight rgbLCD(I2C_SDA, I2C_SCL);
+Grove_temperature temp(A4);
uint32_t button = 0;
-///
-
-float get_temp()
-{
- const int B = 4275; // B value of the thermistor
- const int R0 = 100000; // R0 = 100k
- AnalogIn temp(A4);
-
- float R = 1.0f/temp.read() - 1.0f;
- R = R0*R;
-
- float temperature = 1.0/(log(R/R0)/B+1/298.15)-273.15; // convert to temperature via datasheet
- return temperature;
-}
-///
-
void push()
{
@@ -49,9 +35,8 @@
int cnt = 0;
printf("hello, Mbed world\n");
while (true) {
- printf("count = %4d, button = %d, analog = %f, temp = %f\n", cnt++, button, ain.read(), get_temp());
+ printf("count = %4d, button = %d, analog = %f, temp = %f\n", cnt++, button, ain.read(), temp.getTemperature());
led1 = !led1;
wait(0.5);
}
}
-
