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 #278 background imageLoading...
Page #278 background image
$arduino->parity("none");
-
$arduino->stopbits(1);
15
$arduino->read_const_time(1);
-
$arduino->read_char_time(1);
-
-
sleep(2);
-
while (1) {
20
$arduino->write("a0\n");
-
my ($count, $line) = $arduino->read(255);
-
print $line;
-
}
-
We check whether the name of a serial port was passed on the command line.
Then we create a new
Device::SerialPort
instance in line 11. We configure all
serial port parameters, and in line 16, we set a timeout value for
read
calls. If
we did not set it,
read
would return immediately, giving the Arduino no time
to respond.
read_char_time
sets a timeout for the waiting period between two
characters.
Then we sleep for two seconds and start an infinite loop. Here we send the
string a0 to the serial port and read the Arduinos response using the
read
method.
read
expects a maximum number of bytes to be read, and it returns
the actual number of bytes read and the data it received. Finally, we output
the result to the console. A typical program run looks as follows:
maik> perl analog_reader.pl /dev/tty.usbmodem24321
a0: 496
a0: 366
a0: 320
^C
Thats it! It takes only about twenty lines of Perl code to create a client for the
analog reader Arduino sketch. So, Perl is a good choice for programming
Arduino clients, too.
report erratum discuss
Serial Communication Using Various Languages 265
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