-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
47 lines (47 loc) · 2.05 KB
/
main.ts
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
DFRobotMaqueenPlus.IR_callbackUser(function (value) {
if (value == 32) {
DFRobotMaqueenPlus.mototRun(Motors.M1, Dir.CW, 125)
DFRobotMaqueenPlus.mototRun(Motors.M2, Dir.CW, 0)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBL, Color.YELLOW)
basic.pause(200)
DFRobotMaqueenPlus.mototStop(Motors.ALL)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBA, Color.OFF)
} else if (value == 129) {
DFRobotMaqueenPlus.mototRun(Motors.M1, Dir.CW, 0)
DFRobotMaqueenPlus.mototRun(Motors.M2, Dir.CW, 125)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBR, Color.YELLOW)
basic.pause(200)
DFRobotMaqueenPlus.mototStop(Motors.ALL)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBA, Color.OFF)
} else if (value == 64) {
DFRobotMaqueenPlus.mototRun(Motors.M1, Dir.CW, 125)
DFRobotMaqueenPlus.mototRun(Motors.M2, Dir.CW, 125)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBA, Color.GREEN)
basic.pause(200)
DFRobotMaqueenPlus.mototStop(Motors.ALL)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBA, Color.OFF)
} else if (value == 130) {
DFRobotMaqueenPlus.mototRun(Motors.M1, Dir.CCW, 125)
DFRobotMaqueenPlus.mototRun(Motors.M2, Dir.CCW, 125)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBA, Color.RED)
basic.pause(200)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBA, Color.OFF)
DFRobotMaqueenPlus.mototStop(Motors.ALL)
} else if (value == 33) {
for (let index = 0; index < 4; index++) {
DFRobotMaqueenPlus.mototRun(Motors.M1, Dir.CW, 125)
basic.pause(1000)
DFRobotMaqueenPlus.mototStop(Motors.M1)
DFRobotMaqueenPlus.mototRun(Motors.M2, Dir.CW, 125)
basic.pause(1000)
DFRobotMaqueenPlus.mototStop(Motors.M2)
}
DFRobotMaqueenPlus.mototStop(Motors.ALL)
}
})
let value = 0
DFRobotMaqueenPlus.mototStop(Motors.ALL)
DFRobotMaqueenPlus.setRGBLight(RGBLight.RGBA, Color.OFF)
basic.forever(function () {
value = DFRobotMaqueenPlus.IR_read()
})