From e5dc7e76b839084414ffd06a4df3e0259401386e Mon Sep 17 00:00:00 2001 From: Sergey Alyaev Date: Sun, 7 Aug 2022 16:30:17 +0200 Subject: [PATCH 1/2] Added an example to run basic functionality on the Duplo train --- examples/duplo_test.js | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 examples/duplo_test.js diff --git a/examples/duplo_test.js b/examples/duplo_test.js new file mode 100644 index 0000000..4e86839 --- /dev/null +++ b/examples/duplo_test.js @@ -0,0 +1,29 @@ +const PoweredUP = require(".."); +const poweredUP = new PoweredUP.PoweredUP(); + +poweredUP.on("discover", async (hub) => { // Wait to discover a Hub + console.log(`Discovered ${hub.name}!`); + await hub.connect(); // Connect to the Hub + console.log("Connected"); + let devices = hub.getDevices() + console.log(`Devices ${devices}`); + for (let i = 0; i Date: Sun, 7 Aug 2022 17:03:26 +0200 Subject: [PATCH 2/2] Added an example with led control of Duplo Train --- examples/duplo_test.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/examples/duplo_test.js b/examples/duplo_test.js index 4e86839..527c7d9 100644 --- a/examples/duplo_test.js +++ b/examples/duplo_test.js @@ -6,13 +6,24 @@ poweredUP.on("discover", async (hub) => { // Wait to discover a Hub await hub.connect(); // Connect to the Hub console.log("Connected"); let devices = hub.getDevices() - console.log(`Devices ${devices}`); for (let i = 0; i