-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
81 lines (81 loc) · 2.02 KB
/
main.ts
File metadata and controls
81 lines (81 loc) · 2.02 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
input.onButtonPressed(Button.A, function () {
LED숫자 += 1
LED숫자 = LED숫자 % 4
basic.showNumber(LED숫자)
LED타이머 = 6
})
input.onGesture(Gesture.Shake, function () {
if (램프모드 == 1) {
if (램프상태 == 0) {
램프상태 = 1
} else {
램프상태 = 0
}
}
basic.showNumber(LED숫자)
LED타이머 = 6
})
input.onButtonPressed(Button.AB, function () {
램프모드 = 0
if (램프상태 == 1) {
램프상태 = 0
} else {
램프상태 = 1
}
basic.showNumber(LED숫자)
LED타이머 = 6
})
input.onButtonPressed(Button.B, function () {
램프모드 += 1
램프모드 = 램프모드 % 3
basic.showNumber(램프모드)
LED타이머 = 6
})
let 램프상태 = 0
let 램프모드 = 0
let LED타이머 = 0
let LED숫자 = 0
basic.showNumber(LED숫자)
let strip = neopixel.create(DigitalPin.P0, 5, NeoPixelMode.RGBW)
strip.setBrightness(100)
basic.forever(function () {
if (램프모드 == 2) {
if (input.lightLevel() < 25) {
램프상태 = 1
} else {
램프상태 = 0
}
}
basic.pause(500)
})
basic.forever(function () {
if (램프상태 == 1) {
if (LED숫자 == 0) {
strip.showColor(neopixel.colors(NeoPixelColors.Orange))
} else if (LED숫자 == 1) {
strip.showColor(neopixel.colors(NeoPixelColors.Green))
} else if (LED숫자 == 2) {
strip.showColor(neopixel.colors(NeoPixelColors.Yellow))
} else {
strip.showRainbow(1, 360)
while (LED숫자 == 3 && 램프상태 == 1) {
strip.rotate(1)
strip.show()
basic.pause(500)
}
}
} else {
strip.clear()
strip.show()
}
basic.pause(500)
})
basic.forever(function () {
if (LED타이머 > 0) {
LED타이머 += -1
if (LED타이머 == 0) {
basic.clearScreen()
}
}
basic.pause(500)
})