EasyManuals Logo

Arduino uno User Manual

Arduino uno
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #182 background imageLoading...
Page #182 background image
Well build a system that Tweets a message when the temperature in your
working room or office exceeds a certain threshold32 degrees Celsius (90
degrees Fahrenheit). Build the temperature sensor example from Increasing
Precision Using a Temperature Sensor, on page 86, again (try to do it without
looking at the circuit) and upload the following sketch to your Arduino:
Ethernet/TwitterTemperature/TwitterTemperature.ino
#define CELSIUS
Line 1
const unsigned int TEMP_SENSOR_PIN = 0;
-
const unsigned int BAUD_RATE = 9600;
-
const float SUPPLY_VOLTAGE = 5.0;
-
void setup() {
5
Serial.begin(BAUD_RATE);
-
}
-
-
void loop() {
-
const int sensor_voltage = analogRead(TEMP_SENSOR_PIN);
10
const float voltage = sensor_voltage * SUPPLY_VOLTAGE / 1024;
-
const float celsius = (voltage * 1000 - 500) / 10;
-
#ifdef CELSIUS
-
Serial.print(celsius);
-
Serial.println(" C");
15
#else
-
Serial.print(9.0 / 5.0 * celsius + 32.0);
-
Serial.println(" F");
-
#endif
-
delay(5000);
20
}
-
This is nearly the same sketch weve used before. Keep in mind that you have
to set
SUPPLY_VOLTAGE
to
3.3
in line 4 if youre using an Arduino that runs with
3.3V instead of 5V.
We support both Celsius and Fahrenheit values now, and you can use a
preprocessor constant to control which unit should be used. If you set the
constant
CELSIUS
in the first line, the application outputs the temperature in
degree Celsius. If you remove the first line or turn it into a comment line, the
application will use Fahrenheit.
To change the applications behavior, we use the
#ifdef
preprocessor directive.
It checks whether a certain preprocessor constant has been set, and then it
report erratum discuss
Using Your PC to Transfer Sensor Data to the Internet 165
www.it-ebooks.info

Table of Contents

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino uno and is the answer not in the manual?

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals