-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
61 lines (61 loc) · 2.67 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let moveMotorZIP: Kitronik_Move_Motor.MoveMotorZIP = null
let LED = 0
let B = 0
function Eteint_les_LEDs () {
moveMotorZIP.clear()
moveMotorZIP.show()
}
//% color="#ff6800" icon="\uf1b9" weight=15
//% groups="['Lampes Voiture']"
/**
* car run diretion
*/
//% block="Allume les leds $direction à la vitesse de $speed \\%"
//% speed.min=0 speed.max=100
//% group="Lampes Voiture" weight=99
export function Allume_les_LEDs (Couleur: string) {
moveMotorZIP = Kitronik_Move_Motor.createMoveMotorZIPLED(4)
if (Couleur == "rouge") {
moveMotorZIP.setColor(Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Red))
} else if (Couleur == "orange") {
moveMotorZIP.setColor(Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Orange))
} else if (Couleur == "jaune") {
moveMotorZIP.setColor(Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Yellow))
} else if (Couleur == "vert") {
moveMotorZIP.setColor(Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Green))
} else if (Couleur == "bleu") {
moveMotorZIP.setColor(Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Blue))
} else if (Couleur == "violet") {
moveMotorZIP.setColor(Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Violet))
} else if (Couleur == "rose") {
moveMotorZIP.setColor(Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Indigo))
} else if (Couleur == "police") {
LED = 0
B = 0
while (B != 1) {
moveMotorZIP.setZipLedColor(LED % 4, Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.White))
moveMotorZIP.setZipLedColor((LED + 1) % 4, Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Red))
moveMotorZIP.setZipLedColor((LED + 2) % 4, Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.White))
moveMotorZIP.setZipLedColor((LED + 3) % 4, Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.Blue))
LED = LED + 1
moveMotorZIP.show()
basic.pause(200)
if (input.buttonIsPressed(Button.B)) {
B = 1
}
}
} else if (Couleur == "aléatoire") {
B = 0
while (B != 1) {
moveMotorZIP.showColor(Kitronik_Move_Motor.rgb(randint(0, 255), randint(0, 255), randint(0, 255)))
moveMotorZIP.show()
basic.pause(500)
if (input.buttonIsPressed(Button.B)) {
B = 1
}
}
} else {
moveMotorZIP.setColor(Kitronik_Move_Motor.colors(Kitronik_Move_Motor.ZipLedColors.White))
}
moveMotorZIP.show()
}