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 #268 background imageLoading...
Page #268 background image
Serial Communication Using Various Languages
When working with the Arduino, you often have to talk to it using a serial
port. In this section, youll learn how to do that in various programming lan-
guages. For demonstration purposes, well use the same Arduino sketch for
all of them:
SerialProgramming/AnalogReader/AnalogReader.ino
const unsigned int BAUD_RATE = 9600;
const unsigned int NUM_PINS = 6;
String pin_name = "";
boolean input_available = false;
void setup() {
Serial.begin(BAUD_RATE);
}
void loop() {
if (input_available) {
if (pin_name.length() > 1 &&
(pin_name[0] == 'a' || pin_name[0] == 'A'))
{
const unsigned int pin = pin_name.substring(1).toInt();
if (pin < NUM_PINS) {
Serial.print(pin_name);
Serial.print(": ");
Serial.println(analogRead(pin));
} else {
Serial.print("Unknown pin: ");
Serial.println(pin);
}
} else {
Serial.print("Unknown pin name: ");
Serial.println(pin_name);
}
pin_name = "";
input_available = false;
}
}
void serialEvent() {
while (Serial.available()) {
const char c = Serial.read();
if (c == '\n')
input_available = true;
else
pin_name += c;
}
}
report erratum discuss
Serial Communication Using Various Languages 255
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