File tree 1 file changed +29
-2
lines changed 1 file changed +29
-2
lines changed Original file line number Diff line number Diff line change 20
20
#define DATA_PIN_CHANNEL_1 2
21
21
#define DATA_PIN_CHANNEL_2 3
22
22
23
+ #define BUTTON_PIN 4
24
+
23
25
CRGB ledsChannel1[135 ];
24
26
CRGB ledsChannel2[135 ];
25
27
@@ -33,12 +35,37 @@ void setup() {
33
35
FastLED.addLeds <NEOPIXEL, DATA_PIN_CHANNEL_2>(ledsChannel2, 135 );
34
36
ledController.addLEDs (0 , ledsChannel1, 135 );
35
37
ledController.addLEDs (1 , ledsChannel2, 135 );
38
+ pinMode (BUTTON_PIN, INPUT_PULLUP);
36
39
}
37
40
38
41
void loop () {
42
+ static bool lightingEnabled = true ;
39
43
cHID.update ();
40
44
41
- if (ledController.updateLEDs ()) {
42
- FastLED.show ();
45
+ if (buttonClicked ()) {
46
+ lightingEnabled = !lightingEnabled;
47
+ fill_solid (ledsChannel1, 135 , CRGB::Black);
48
+ fill_solid (ledsChannel2, 135 , CRGB::Black);
49
+ FastLED.show ();
50
+ }
51
+
52
+ if (lightingEnabled && ledController.updateLEDs ()) {
53
+ FastLED.show ();
43
54
}
44
55
}
56
+
57
+ /* *
58
+ * Handle button of the LS100. The button is optional.
59
+ *
60
+ * @return true if the button was pressed and then released.
61
+ */
62
+ bool buttonClicked () {
63
+ static bool previousState = 1 ;
64
+ bool state = digitalRead (BUTTON_PIN);
65
+ if (previousState == 0 && state == 1 ) {
66
+ previousState = state;
67
+ return true ;
68
+ }
69
+ previousState = state;
70
+ return false ;
71
+ }
You can’t perform that action at this time.
0 commit comments