Last change
on this file since 136 was 136, checked in by ertl-honda, 8 years ago |
ライブラリとOS及びベーシックなサンプルの追加.
|
File size:
870 bytes
|
Rev | Line | |
---|
[136] | 1 | /*
|
---|
| 2 | Esplora Temperature Sensor
|
---|
| 3 |
|
---|
| 4 | This sketch shows you how to read the Esplora's temperature sensor
|
---|
| 5 | You can read the temperature sensor in Farhenheit or Celsius.
|
---|
| 6 |
|
---|
| 7 | Created on 22 Dec 2012
|
---|
| 8 | by Tom Igoe
|
---|
| 9 |
|
---|
| 10 | This example is in the public domain.
|
---|
| 11 | */
|
---|
| 12 | #include <Esplora.h>
|
---|
| 13 |
|
---|
| 14 | void setup()
|
---|
| 15 | {
|
---|
| 16 | Serial.begin(9600); // initialize serial communications with your computer
|
---|
| 17 | }
|
---|
| 18 |
|
---|
| 19 | void loop()
|
---|
| 20 | {
|
---|
| 21 | // read the temperature sensor in Celsius, then Fahrenheit:
|
---|
| 22 | int celsius = Esplora.readTemperature(DEGREES_C);
|
---|
| 23 | int fahrenheit = Esplora.readTemperature(DEGREES_F);
|
---|
| 24 |
|
---|
| 25 | // print the results:
|
---|
| 26 | Serial.print("Temperature is: ");
|
---|
| 27 | Serial.print(celsius);
|
---|
| 28 | Serial.print(" degrees Celsius, or ");
|
---|
| 29 | Serial.print(fahrenheit);
|
---|
| 30 | Serial.println(" degrees Fahrenheit.");
|
---|
| 31 | Serial.println(" Fahrenheit = (9/5 * Celsius) + 32");
|
---|
| 32 |
|
---|
| 33 | // wait a second before reading again:
|
---|
| 34 | delay(1000);
|
---|
| 35 | }
|
---|
| 36 |
|
---|
| 37 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.