-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
26 lines (18 loc) · 776 Bytes
/
example.js
File metadata and controls
26 lines (18 loc) · 776 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
// This example file is meant to give you an idea of some of the basic
// Sphero commands. Refer to this when solving activities 1 & 2.
var sphero = require('./sphero.js');
// First step is to connect to Sphero
sphero.connect(function() {
// Move Sphero a distance of 200 units at an angle of 90 degrees
sphero.roll(10,20)
// Get Sphero's color
console.log("Sphero's current color is: " + sphero.getColor());
// Change Sphero's color
sphero.setColor('blue');
// Verify Sphero's color has changed
console.log("Sphero's current color is: " + sphero.getColor());
// Use the Odometer to find Sphero's position in format [x,y]
console.log(sphero.readOdometer());
// Check if Sphero's state is what is expected
sphero.assertState(0, 200, 'blue');
});