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 #291 background imageLoading...
Page #291 background image
ChromeApps/SerialDevice/main.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<title>Serial Device Demo</title>
</head>
<body>
<div id="main">
<p>The Arduino sends:</p>
<p id="output"></p>
</div>
<script src="js/serial_device.js"></script>
<script src="js/arduino.js"></script>
</body>
</html>
In the HTML page, youll find a paragraph element with its
id
attribute set to
output
. Thats the element well fill with the data we read from the serial port.
At the end of the document, we include our new JavaScript library for
accessing the serial device. Also, we include a file named
arduino.js
:
ChromeApps/SerialDevice/js/arduino.js
var arduino = new SerialDevice('/dev/tty.usbmodem24311');
arduino.onConnect.addListener(function() {
console.log('Connected to: ' + arduino.path);
});
arduino.onReadLine.addListener(function(line) {
console.log('Read line: ' + line);
document.getElementById('output').innerText = line;
});
arduino.connect();
Here we create a new
SerialDevice
object named
arduino
. Then we add listener
functions for the
onConnect
and
onReadLine
events. Both write a message to the
console. The
onReadLine
listener puts the line it has read into the browsers
Document Object Model (DOM).
Make sure you use the correct serial port in the first line of
arduino.js
. Then
connect your Arduino to your computer and upload a sketch that permanently
outputs lines of text on the serial port. You can use the sketch from Building
Your Own Game Controller, on page 106. Start the Chrome app, and you should
see something like the following figure:
report erratum discuss
Writing a SerialDevice Class 279
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