Better example
This commit is contained in:
parent
4fc8e578c9
commit
990beabb3a
13
ABOUT.md
13
ABOUT.md
@ -58,11 +58,14 @@ const poweredUP = new PoweredUP.PoweredUP();
|
||||
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.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.sleep(1000); // Do nothing for 1 second
|
||||
await hub.setMotorSpeed("A", 75); // Activate a motor attached to port A at 3/4 speed (75) indefinitely
|
||||
|
||||
while (true) { // Repeat indefinitely
|
||||
hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
|
||||
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.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.sleep(1000); // Do nothing for 1 second
|
||||
}
|
||||
});
|
||||
|
||||
poweredUP.scan(); // Start scanning for Hubs
|
||||
|
13
README.md
13
README.md
@ -58,11 +58,14 @@ const poweredUP = new PoweredUP.PoweredUP();
|
||||
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.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.sleep(1000); // Do nothing for 1 second
|
||||
await hub.setMotorSpeed("A", 75); // Activate a motor attached to port A at 3/4 speed (75) indefinitely
|
||||
|
||||
while (true) { // Repeat indefinitely
|
||||
hub.setMotorSpeed("B", 75); // Start a motor attached to port B to run a 3/4 speed (75) indefinitely
|
||||
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.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.sleep(1000); // Do nothing for 1 second
|
||||
}
|
||||
});
|
||||
|
||||
poweredUP.scan(); // Start scanning for Hubs
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "node-poweredup",
|
||||
"version": "1.0.10",
|
||||
"version": "1.0.11",
|
||||
"description": "A Node.js module to interface with LEGO Powered UP components.",
|
||||
"homepage": "https://github.com/nathankellenicki/node-poweredup/",
|
||||
"main": "dist/poweredup.js",
|
||||
|
Loading…
x
Reference in New Issue
Block a user