2017-12-19 23:55:48 +01:00
|
|
|
tests.test("Detect color red", function () {
|
|
|
|
brick.print("Point sensor to red", 0, 50)
|
|
|
|
brick.print("and click enter", 0, 60)
|
2018-01-31 17:28:00 +01:00
|
|
|
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped)
|
2017-12-19 23:55:48 +01:00
|
|
|
brick.clearScreen()
|
|
|
|
let actualColor = sensors.color1.color()
|
|
|
|
tests.assertClose("Color", actualColor, ColorSensorColor.Red, 0)
|
|
|
|
})
|
|
|
|
|
|
|
|
tests.test("Bright ambient light", function () {
|
|
|
|
brick.print("Point sensor to ceiling", 0, 50)
|
|
|
|
brick.print("light and click enter", 0, 60)
|
2018-01-31 17:28:00 +01:00
|
|
|
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped)
|
2017-12-19 23:55:48 +01:00
|
|
|
brick.clearScreen()
|
|
|
|
let actualLight: number
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
|
|
actualLight = sensors.color1.ambientLight()
|
2018-02-15 01:05:31 +01:00
|
|
|
pause(500)
|
2017-12-19 23:55:48 +01:00
|
|
|
}
|
|
|
|
tests.assertClose("Light", actualLight, 20, 15)
|
|
|
|
})
|
|
|
|
|
|
|
|
tests.test("Bright reflected light", function () {
|
|
|
|
brick.print("Point sensor to white", 0, 50)
|
|
|
|
brick.print("desk surface", 0, 60)
|
|
|
|
brick.print("and click enter", 0, 70)
|
2018-01-31 17:28:00 +01:00
|
|
|
brick.buttonEnter.pauseUntil(ButtonEvent.Bumped)
|
2017-12-19 23:55:48 +01:00
|
|
|
brick.clearScreen()
|
|
|
|
let actualLight: number
|
|
|
|
for (let i = 0; i < 4; i++) {
|
|
|
|
actualLight = sensors.color1.reflectedLight()
|
2018-02-15 01:05:31 +01:00
|
|
|
pause(500)
|
2017-12-19 23:55:48 +01:00
|
|
|
}
|
|
|
|
tests.assertClose("Light", actualLight, 17, 14)
|
|
|
|
})
|