#include "USB.h" #include "USBHIDKeyboard.h" #include USBHIDKeyboard Keyboard; #define IR_PIN D2 #define PIXEL_PIN D4 #define NUMPIXELS 28 Adafruit_NeoPixel strip(NUMPIXELS, PIXEL_PIN, NEO_GRB + NEO_KHZ800); int stage = 0; bool armed = true; void sendSpace() { Keyboard.write(' '); } void pixelsOn() { for (int i = 0; i < NUMPIXELS; i++) { strip.setPixelColor(i, strip.Color(255, 255, 255)); } strip.show(); } void pixelsOff() { strip.clear(); strip.show(); } void setup() { pinMode(IR_PIN, INPUT); strip.begin(); pixelsOff(); Keyboard.begin(); USB.begin(); } void loop() { bool state = digitalRead(IR_PIN); if (state == HIGH && armed) { switch (stage) { case 0: sendSpace(); // Wave 1 light on stage = 1; break; case 1: pixelsOn(); // Wave 2 space light off stage = 2; break; case 2: sendSpace(); // Wave 3 space pixelsOff(); stage = 0; break; } armed = false; } if (state == LOW) { armed = true; } delay(1000); // 1 second lockout }