VPX Functions
Lights
Rainbow Changing Lights
1min
VisualBasic
1
2 '*************************
3 ' Rainbow Changing Lights
4 '*************************
5
6 Dim RGBStep, RGBFactor, rRed, rGreen, rBlue, RainbowLights
7
8 Sub StartRainbow(n)
9 set RainbowLights = n
10 RGBStep = 0
11 RGBFactor = 5
12 rRed = 255
13 rGreen = 0
14 rBlue = 0
15 RainbowTimer.Enabled = 1
16 End Sub
17
18 Dim RGBStep2, RGBFactor2, rRed2, rGreen2, rBlue2, RainbowLights2
19 Sub StartRainbow2(n)
20 set RainbowLights2 = n
21 RGBStep2 = 0
22 RGBFactor2 = 5
23 rRed2 = 255
24 rGreen2 = 0
25 rBlue2 = 0
26 RainbowTimer1.Enabled = 1
27 End Sub
28
29 Sub StopRainbow(n)
30 Dim obj
31 RainbowTimer.Enabled = 0
32 RainbowTimer.Enabled = 0
33 For each obj in RainbowLights
34 SetLightColor obj, "white", 0
35 Next
36 End Sub
37
38 Sub StopRainbow2(n)
39 Dim obj
40 RainbowTimer1.Enabled = 0
41 For each obj in RainbowLights2
42 SetLightColor obj, "white", 0
43 obj.state = 1
44 obj.Intensity = 7
45 Next
46 End Sub
47
48 Sub RainbowTimer_Timer 'rainbow led light color changing
49 Dim obj
50 Select Case RGBStep
51 Case 0 'Green
52 rGreen = rGreen + RGBFactor
53 If rGreen > 255 then
54 rGreen = 255
55 RGBStep = 1
56 End If
57 Case 1 'Red
58 rRed = rRed - RGBFactor
59 If rRed < 0 then
60 rRed = 0
61 RGBStep = 2
62 End If
63 Case 2 'Blue
64 rBlue = rBlue + RGBFactor
65 If rBlue > 255 then
66 rBlue = 255
67 RGBStep = 3
68 End If
69 Case 3 'Green
70 rGreen = rGreen - RGBFactor
71 If rGreen < 0 then
72 rGreen = 0
73 RGBStep = 4
74 End If
75 Case 4 'Red
76 rRed = rRed + RGBFactor
77 If rRed > 255 then
78 rRed = 255
79 RGBStep = 5
80 End If
81 Case 5 'Blue
82 rBlue = rBlue - RGBFactor
83 If rBlue < 0 then
84 rBlue = 0
85 RGBStep = 0
86 End If
87 End Select
88 For each obj in RainbowLights
89 obj.color = RGB(rRed \ 10, rGreen \ 10, rBlue \ 10)
90 obj.colorfull = RGB(rRed, rGreen, rBlue)
91 Next
92 End Sub
93
94 Sub RainbowTimer1_Timer 'rainbow led light color changing
95 Dim obj
96 Select Case RGBStep2
97 Case 0 'Green
98 rGreen2 = rGreen2 + RGBFactor2
99 If rGreen2 > 255 then
100 rGreen2 = 255
101 RGBStep2 = 1
102 End If
103 Case 1 'Red
104 rRed2 = rRed2 - RGBFactor2
105 If rRed2 < 0 then
106 rRed2 = 0
107 RGBStep2 = 2
108 End If
109 Case 2 'Blue
110 rBlue2 = rBlue2 + RGBFactor2
111 If rBlue2 > 255 then
112 rBlue2 = 255
113 RGBStep2 = 3
114 End If
115 Case 3 'Green
116 rGreen2 = rGreen2 - RGBFactor2
117 If rGreen2 < 0 then
118 rGreen2 = 0
119 RGBStep2 = 4
120 End If
121 Case 4 'Red
122 rRed2 = rRed2 + RGBFactor2
123 If rRed2 > 255 then
124 rRed2 = 255
125 RGBStep2 = 5
126 End If
127 Case 5 'Blue
128 rBlue2 = rBlue2 - RGBFactor2
129 If rBlue2 < 0 then
130 rBlue2 = 0
131 RGBStep2 = 0
132 End If
133 End Select
134 ' For each obj in RainbowLights2
135 ' obj.color = RGB(rRed2 \ 10, rGreen2 \ 10, rBlue2 \ 10)
136 ' obj.colorfull = RGB(rRed2, rGreen2, rBlue2)
137 ' Next
138 End Sub