Fixed example

This commit is contained in:
Nathan Kunicki 2018-08-14 12:54:01 +01:00
parent 17f638580c
commit 4fc8e578c9
3 changed files with 5 additions and 1 deletions

View File

@ -56,6 +56,8 @@ const PoweredUP = require("node-poweredup");
const poweredUP = new PoweredUP.PoweredUP(); const poweredUP = new PoweredUP.PoweredUP();
poweredUP.on("discover", async (hub) => { // Wait to discover a Hub poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
await hub.connect(); // Connect to the Hub
await hub.sleep(3000); // Sleep for 3 seconds before starting
await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
await hub.sleep(1000); // Do nothing for 1 second await hub.sleep(1000); // Do nothing for 1 second
await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop

View File

@ -56,6 +56,8 @@ const PoweredUP = require("node-poweredup");
const poweredUP = new PoweredUP.PoweredUP(); const poweredUP = new PoweredUP.PoweredUP();
poweredUP.on("discover", async (hub) => { // Wait to discover a Hub poweredUP.on("discover", async (hub) => { // Wait to discover a Hub
await hub.connect(); // Connect to the Hub
await hub.sleep(3000); // Sleep for 3 seconds before starting
await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop await hub.setMotorSpeed("A", 100, 2000); // Run a motor attached to port A for 2 seconds at maximum speed (100) then stop
await hub.sleep(1000); // Do nothing for 1 second await hub.sleep(1000); // Do nothing for 1 second
await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop await hub.setMotorSpeed("A", -50, 1000); // Run a motor attached to port A for 1 second at 1/2 speed in reverse (-50) then stop

View File

@ -1,6 +1,6 @@
{ {
"name": "node-poweredup", "name": "node-poweredup",
"version": "1.0.9", "version": "1.0.10",
"description": "A Node.js module to interface with LEGO Powered UP components.", "description": "A Node.js module to interface with LEGO Powered UP components.",
"homepage": "https://github.com/nathankellenicki/node-poweredup/", "homepage": "https://github.com/nathankellenicki/node-poweredup/",
"main": "dist/poweredup.js", "main": "dist/poweredup.js",