From 70f7979811facfaefcdf361b4e30eb190cf6d5c7 Mon Sep 17 00:00:00 2001 From: Christian Langer Date: Thu, 27 Feb 2025 17:24:38 +0100 Subject: [PATCH] First Commit --- LED_Helmet.ino | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) create mode 100644 LED_Helmet.ino diff --git a/LED_Helmet.ino b/LED_Helmet.ino new file mode 100644 index 0000000..cc27daf --- /dev/null +++ b/LED_Helmet.ino @@ -0,0 +1,97 @@ +#define Blinker_Right 17 +#define Blinker_Left 16 +#define Brightness_Toggle 15 +#define BR_LED_PIN 12 +#define BL_LED_PIN 13 +#define BRK_LED_PIN 14 +#define Blinker_Pixels 8 +#define BRK_Pixels 12 +#define Pixel_SPD 100 +#include + + +Adafruit_NeoPixel BL_LED(Blinker_Pixels, BL_LED_PIN, NEO_GRB + NEO_KHZ800); +Adafruit_NeoPixel BR_LED(Blinker_Pixels, BR_LED_PIN, NEO_GRB + NEO_KHZ800); +Adafruit_NeoPixel BRK_LED(BRK_Pixels, BRK_LED_PIN, NEO_GRB + NEO_KHZ800); +void clearLEDs(){ + BL_LED.clear(); + BR_LED.clear(); + BRK_LED.clear(); +} +void setup() { + Serial.begin(57600); + // put your setup code here, to run once: + pinMode(Blinker_Right,INPUT); + pinMode(Blinker_Left,INPUT); + pinMode(Brightness_Toggle,INPUT); + BL_LED.begin(); + BR_LED.begin(); + BRK_LED.begin(); + +} +int BR_LED_State = 0; +int BL_LED_State = 0; +int BRK_LED_State = 0; + +int BR_State = 0; +int BR_active = 0; +int BL_State = 0; +int BL_active = 0; +int Brightness_toggle_state = 0; +int Brightness_toggle_active = 0; +int old_state = 0; +void loop() { + old_state = BR_State; + BR_State = digitalRead(Blinker_Right); + if(BR_State != old_state && old_state ==0) BR_active = !BR_active; + old_state = BL_State; + BL_State = digitalRead(Blinker_Left); + if(BL_State != old_state && old_state ==0) BL_active = !BL_active; + old_state = Brightness_toggle_state; + Brightness_toggle_state = digitalRead(Brightness_Toggle); + if(Brightness_toggle_state != old_state && old_state ==0) Brightness_toggle_active = !Brightness_toggle_active; + if(!BR_active){ //Right Blinker Active + + BR_LED_State = 0; + } + else{ + BR_LED_State = (BR_LED_State+1)%(Blinker_Pixels+1); + } + if(!BL_active){ //Left Blinker Active + BL_LED_State = 0; + } + else{ + BL_LED_State = (BL_LED_State+1)%(Blinker_Pixels+1); + } + if(!Brightness_toggle_active){ //Break Lights Active + BRK_LED_State = 0; + } + else{ + BRK_LED_State = (BRK_LED_State+1)%(BRK_Pixels+1); + } + + // put your main code here, to run repeatedly: + BR_LED.clear(); + BL_LED.clear(); + BRK_LED.clear(); + for(int pixel = 0;pixel