Skip to content

Instantly share code, notes, and snippets.

@BarrYPL
Created April 29, 2018 21:56
Show Gist options
  • Save BarrYPL/2583a3406e767e0d74e775ca9bc473ac to your computer and use it in GitHub Desktop.
Save BarrYPL/2583a3406e767e0d74e775ca9bc473ac to your computer and use it in GitHub Desktop.
#include <Keyboard.h>
#include <FastLED.h>
#include <Adafruit_NeoPixel.h>
#define FASTLED_ALLOW_INTERRUPTS 0
#define NUM_LEDS 24
#define LED_PIN 5
#define LED_TYPE WS2811
#define COLOR_ORDER GRB
#define ANALOG_READ 0
CRGB led[NUM_LEDS];
#define BRIGHTNESS 255
#define FRAMES_PER_SECOND 120
int ledPin1 = 4;
int inPin1 = 8;
int ledPin2 = 6;
int inPin2 = 9;
int val1 = 0;
int val2 = 0;
int i;
void setup() {
FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(led, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
Serial.begin (28800);
pinMode(ledPin1, OUTPUT);
pinMode(inPin1, INPUT);
pinMode(ledPin2, OUTPUT);
pinMode(inPin2, INPUT);
Keyboard.begin();
}
void AllPink() {
for (int i = 0; i < NUM_LEDS; i++) {
led[i] = CRGB(155, 0, 155);
}
FastLED.show();
}
void Reset() {
for (int i = 0; i < NUM_LEDS; i++) {
led[i] = CRGB(0, 0, 0);
}
FastLED.show();
}
void loop() {
val1 = digitalRead(inPin1);
val2 = digitalRead(inPin2);
if (val1 != HIGH && val2 != HIGH) {
digitalWrite(ledPin1, LOW);
Keyboard.release('x');
digitalWrite(ledPin2, LOW);
Keyboard.release('z');
for (i = 0; i < 255; i++) {
val1 = digitalRead(inPin1);
val2 = digitalRead(inPin2);
if (val1 == HIGH) {
break;
}
if (val2 == HIGH) {
break;
}
fill_rainbow(led, NUM_LEDS, i);
FastLED.show();
}
}
else
{
val1 = digitalRead(inPin1);
val2 = digitalRead(inPin2);
Reset();
if (val1 == HIGH) {
digitalWrite(ledPin1, HIGH);
Keyboard.press('x');
AllPink();
}
if (val2 == HIGH) {
digitalWrite(ledPin2, HIGH);
Keyboard.press('z');
AllPink();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment