-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
33 lines (33 loc) · 1.25 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
let sensorRechts = 0
let sensorLinks = 0
basic.forever(function () {
let verschilSenoren = 0
sensorRechts = Kitronik_Move_Motor.readSensor(Kitronik_Move_Motor.LfSensor.Right)
sensorLinks = Kitronik_Move_Motor.readSensor(Kitronik_Move_Motor.LfSensor.Left)
sensorLinks = sensorLinks - sensorRechts
if (verschilSenoren > 10) {
if (sensorLinks > sensorRechts) {
Kitronik_Move_Motor.motorOff(Kitronik_Move_Motor.Motors.MotorRight)
Kitronik_Move_Motor.motorOn(Kitronik_Move_Motor.Motors.MotorLeft, Kitronik_Move_Motor.MotorDirection.Forward, 30)
basic.showLeds(`
. . # . .
. # . . .
# . # # #
. # . . .
. . # . .
`)
} else {
Kitronik_Move_Motor.motorOff(Kitronik_Move_Motor.Motors.MotorRight)
Kitronik_Move_Motor.motorOn(Kitronik_Move_Motor.Motors.MotorLeft, Kitronik_Move_Motor.MotorDirection.Forward, 30)
basic.showLeds(`
. . # . .
. . . # .
# # # . #
. . . # .
. . # . .
`)
}
} else {
Kitronik_Move_Motor.move(Kitronik_Move_Motor.DriveDirections.Forward, 30)
}
})