EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
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 #284 background imageLoading...
Page #284 background image
page. If you click it, Chrome will open a console for the background page.
Also, it automatically creates another link next to it, pointing to the applica-
tions main page. If you click this link, youll get access to all of your applica-
tions innardsthat is, youll get a JavaScript console for your running Chrome
App.
Because our first Chrome apps manifest requests permission for accessing
the serial port, you can use Chromes serial API
6
in the applications JavaScript
console.
The following function prints the paths to all serial devices connected to your
computer (to enter multi-line functions in the JavaScript console, press
Shift+Enter at the end of each line):
chrome.serial.getDevices(function(devices) {
devices.forEach(function(d) {
console.log(d.path);
})
});
On my machine this function outputs the following:
/dev/cu.Bluetooth-Incoming-Port
/dev/tty.Bluetooth-Incoming-Port
/dev/cu.Bluetooth-Modem
/dev/tty.Bluetooth-Modem
/dev/cu.usbmodem24321
/dev/tty.usbmodem24321
The last two lines represent the serial port connected to my Arduino. With
the following statement you can connect to the Arduino from the JavaScript
console:
chrome.serial.connect(
"/dev/tty.usbmodem24321",
{ bitrate: 38400 },
function(c) { console.log(c) })
chrome.serial.connect
expects three arguments. The first is the path to the serial
port to connect to. With the second argument, you can specify typical options
for serial ports, such as the baud rate (named
bitrate
in this case) or the parity
bit. Eventually you have to pass a callback function that gets called after
Chrome tries to establish the connection.
6.
https://developer.chrome.com/apps/serial
Appendix 4. Controlling the Arduino with a Browser 272
report erratum discuss
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals