Skip to content

Commit 93babb6

Browse files
author
Alan Shaw
committed
Fix #7
1 parent 7082915 commit 93babb6

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

exercises/street_lamp/exercise.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ exercise = wrappedexec(exercise)
2121
// this actually runs the solution
2222
exercise.addProcessor(function (mode, callback) {
2323
// includes the solution to run it
24-
proxyquire(path.join(process.cwd(), exercise.args[0]), {'johnny-five': five.spyOn('Led')})
24+
proxyquire(path.join(process.cwd(), exercise.args[0]), {'johnny-five': five.spyOn('Led', 'Sensor')})
2525

2626
setTimeout(function() {
2727
console.log('Please wait while your solution is tested...')
@@ -57,10 +57,14 @@ exercise.addVerifyProcessor(function (callback) {
5757
expect(analogReadListener, 'No values were read from A0').to.not.be.null
5858

5959
var led = five.Led.instances[0]
60+
var sensor = five.Sensor.instances[0]
6061

6162
expect(led, 'no led instance created').to.exist
6263
expect(led.pin, 'led expected to be connected to pin 9').to.equal(9)
6364

65+
// User may have set a high value for analog noise filtering
66+
var freq = sensor ? sensor.freq : 100
67+
6468
analogReadListener(random(600, 900))
6569

6670
setTimeout(function () {
@@ -95,9 +99,9 @@ exercise.addVerifyProcessor(function (callback) {
9599
} catch (er) {
96100
callback(er, false)
97101
}
98-
}, 100)
99-
}, 100)
100-
}, 100)
102+
}, freq)
103+
}, freq)
104+
}, freq)
101105

102106
} catch (e) {
103107
callback(e, false)

exercises/street_lamp/solution/solution.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ board.on('ready', function () {
55
var led = new five.Led(9)
66
var pr = new five.Sensor('A0')
77

8-
pr.on('data', function () {
8+
pr.on('change', function () {
99
if (this.value > 600) {
1010
led.on()
1111
} else {

0 commit comments

Comments
 (0)