Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve second example #218

Merged
merged 1 commit into from
Jun 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/firmata-io/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ const Firmata = require("firmata-io").Firmata;

Serialport.list().then(ports => {
// Figure which port to use...
const port = ports.find(port => port.manufacturer.startsWith("Arduino"));
const port = ports.find(port => {
return port.manufacturer && port.manufacturer.startsWith("Arduino")
});

// Instantiate an instance of your Transport class
const transport = new Serialport(port.path);

// Pass the new instance directly to the Firmata class
const board = new Firmata(transport);

board.on("connect", () => console.log("Connected!"));

board.on("close", () => {
// Unplug the board to see this event!
console.log("Closed!");
Expand Down