source: rtos_arduino/trunk/arduino_lib/libraries/LuckyShield/examples/WeatherStation/WeatherStation.ino@ 175

Last change on this file since 175 was 175, checked in by ertl-honda, 8 years ago

ライブラリを Arduino IDE 1.7.9 にupdate

File size: 1.3 KB
Line 
1/*
2Weather Station
3
4A simple Arduino sketch that reads values from temperature, humidity and pressure sensors
5of the Lucky Shield and display it in the OLED add-on (and also via Serial).
6
7created Mar 2016
8by andrea@arduino.org,
9 sergio@arduino.org
10*/
11
12#include <Lucky.h>
13#include <Wire.h>
14
15String tmp_lbl, tmp_um, tmp_val, hum_lbl, hum_um, hum_val, pre_lbl, pre_um, pre_val;
16void setup() {
17 Serial.begin(9600);
18
19 lucky.begin();
20
21 //setup the Lucky OLED
22 lucky.oled().setTextSize(0.5);
23 lucky.oled().setTextColor(WHITE);
24 lucky.oled().clearDisplay();
25
26 tmp_lbl = "Temper.: ";
27 hum_lbl = "Humidity:";
28 pre_lbl = "Pressure:";
29
30 tmp_um = " C.";
31 hum_um = " %";
32 pre_um = " hPa";
33}
34
35void loop() {
36
37 lucky.oled().clearDisplay();
38
39 tmp_val = String(lucky.environment().temperature());
40 lucky.oled().setCursor(5, 10);
41 lucky.oled().print(tmp_lbl + tmp_val + tmp_um);
42 Serial.println(tmp_lbl + tmp_val + tmp_um);
43
44 hum_val = String(lucky.environment().humidity());
45 lucky.oled().setCursor(5, 30);
46 lucky.oled().print(hum_lbl + hum_val + hum_um);
47 Serial.println(hum_lbl + hum_val + hum_um);
48
49 pre_val = String(lucky.environment().pressure() / 100.0F);
50 lucky.oled().setCursor(5, 50);
51 lucky.oled().print(pre_lbl + pre_val + pre_um);
52 Serial.println(pre_lbl + pre_val + pre_um);
53
54 lucky.oled().display();
55
56 delay(1000);
57}
Note: See TracBrowser for help on using the repository browser.