My push buttons to open apps to test my macro pad only work when my LED strip is set to pink or red. any help is appreciated. (new to arduino btw)
#include <FastLED.h>
#include <Keyboard.h>
#define NUM_LEDS 144 /* The amount of pixels/leds you have /
#define DATA_PIN 2 / The pin your data line is connected to /
#define LED_TYPE WS2812B / I assume you have WS2812B leds, if not just change it to whatever you have /
#define BRIGHTNESS 255 / Control the brightness of your leds /
#define SATURATION 255 / Control the saturation of your leds */
#define KEY16 16
#define KEY10 10
#define LEDKEY 14
//const int buttonpin = 14;
//int colors[13] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360};
//int c = 0;
static int p = 1;
CRGB leds[NUM_LEDS];
void setcolor(int hue) {
for (int id = 0; id < NUM_LEDS; id++) {
leds[id] = CHSV(hue, 255, 0);
FastLED.show();
delay(0.1);
}
for (int id = NUM_LEDS; id > 0; id--) {
leds[id] = CHSV(hue, 255, 255);
FastLED.show();
delay(0.1);
}
}
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN>(leds, NUM_LEDS);
pinMode(LEDKEY, INPUT_PULLUP);
// Serial.begin(9600);
pinMode (KEY16, INPUT_PULLUP);
pinMode (KEY10, INPUT_PULLUP);
Keyboard.begin();
for (int id = 0; id < NUM_LEDS; id++) {
leds[id] = CHSV(0, 255, 255);
FastLED.show();
delay(0.1);
}
for (int id = 0; id < NUM_LEDS; id++) {
leds[id] = CHSV(0, 255, 0);
FastLED.show();
delay(0.1);
}
}
void loop() {
if (digitalRead(LEDKEY) == HIGH) {
p++;
// Serial.print("P is now ");
// Serial.println(p);
if (p == 1) {
setcolor(160);
} else if (p == 2) {
setcolor(0);
} else if (p == 3) {
setcolor(128);
} else if (p == 4) {
setcolor(224);
} else if (p == 5) {
setcolor(96);
} else if (p == 6) {
// Serial.println("Rolling over");
p = 1;
setcolor(160);
}
}
if (digitalRead(KEY16) == HIGH) {
// Serial.println("Opening camera");
Keyboard.press(KEY_LEFT_GUI);
delay(100);
Keyboard.releaseAll();
delay(150);
Keyboard.print("camera");
delay(200);
Keyboard.press(KEY_RETURN);
delay(100);
//change the keyname in the parenthese to any from:https://www.arduino.cc/en/Reference/KeyboardModifiers, if you want multiple, duplicate this command//
delay(100); //this sets a delay so the keybind doesnt spam, and only goes once per 100 milliseconds in this case//
}
if (digitalRead(KEY10) == HIGH) {
// Serial.println("Opening calculator");
Keyboard.press(KEY_LEFT_GUI);
delay(100);
Keyboard.releaseAll();
delay(150);
Keyboard.print("Calculator");
delay(200);
Keyboard.press(KEY_RETURN);
delay(100);
//change the keyname in the parenthese to any from:https://www.arduino.cc/en/Reference/KeyboardModifiers, if you want multiple, duplicate this command//
delay(100); //this sets a delay so the keybind doesnt spam, and only goes once per 100 milliseconds in this case//
}
if (digitalRead(KEY10) == LOW && digitalRead(KEY16) == LOW) {
Keyboard.releaseAll();
}
}