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 #98 background imageLoading...
Page #98 background image
Figure 15PING))) basic circuit
digitalWrite(PING_SENSOR_IO_PIN, LOW);
15
-
pinMode(PING_SENSOR_IO_PIN, INPUT);
-
const unsigned long duration = pulseIn(PING_SENSOR_IO_PIN, HIGH);
-
if (duration == 0) {
-
Serial.println("Warning: We did not get a pulse from sensor.");
20
} else {
-
Serial.print("Distance to nearest object: ");
-
Serial.print(microseconds_to_cm(duration));
-
Serial.println(" cm");
-
}
25
-
delay(100);
-
}
-
-
unsigned long microseconds_to_cm(const unsigned long microseconds) {
30
return microseconds / 29 / 2;
-
}
-
First we define a constant for the IO pin the PING))) sensor is connected to.
If you want to connect your sensor to another digital IO pin, you have to
change the programs first line. In the
setup
method, we set the serial ports
baud rate to 9600, because wed like to see some sensor data on the serial
monitor.
Chapter 5. Sensing the World Around Us 80
report erratum discuss
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