#include <FastLED.h>
#define NUM_LEDS 32
#define DATA_PIN 2
#define SWITCH_PIN A0
#define SWITCH_PIN_2 A1 // Define the pin for the switch
#define SWITCH_PIN_3 A2
#define fliRel 11
#define rpm_p A4
#define speed_p A3
#define Led_tl 13
#define Led_tr 12
#define Led_dri 0
#define Led_frl 8
#define Led_haz 15
#define Led_hor 14
#define frosw A12
#define drifbu A9
#define hazsw A14
#define buzbut A10
#define buzpin 19
int x;
#define DELAY_TIME 80 // Adjust this value for the speed of the swipe
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
FastLED.clear();
FastLED.show();
pinMode(SWITCH_PIN, INPUT_PULLUP);
pinMode(SWITCH_PIN_2, INPUT_PULLUP);
pinMode(SWITCH_PIN_3, INPUT_PULLUP);
pinMode(drifbu, INPUT_PULLUP);
pinMode(frosw, INPUT_PULLUP);
pinMode(buzbut, INPUT_PULLUP);
pinMode(Led_tl, OUTPUT);
pinMode(Led_tr, OUTPUT);
pinMode(Led_dri, OUTPUT);
pinMode(Led_frl, OUTPUT);
pinMode(Led_haz, OUTPUT);
pinMode(Led_hor, OUTPUT);
pinMode(fliRel, OUTPUT);
}
void loop() {
int switchState = analogRead(SWITCH_PIN);
int switchState_2 = analogRead(SWITCH_PIN_2);
int switchState_3 = analogRead(SWITCH_PIN_3);
if (analogRead(buzbut) == LOW) {
tone(buzpin, 500, 500);
digitalWrite(Led_hor, HIGH);}
else {digitalWrite(Led_hor, LOW);}
if (analogRead(drifbu) == LOW) {
digitalWrite(Led_dri, HIGH);}
else {
digitalWrite(Led_dri, LOW);}
if (analogRead(frosw) == LOW) {
digitalWrite(Led_frl, HIGH);
digitalWrite(fliRel, HIGH);}
else {
digitalWrite(Led_frl, LOW);
digitalWrite(fliRel, LOW);}
if (analogRead(hazsw) == LOW) {
digitalWrite(Led_haz, HIGH);}
else {
digitalWrite(Led_haz, LOW);}
if (switchState == LOW) { // If the switch is pressed (LOW state)
swipeAnimation(); // Execute swipe animation
} else if (switchState_2 == LOW) { // If the switch is not pressed (HIGH state)
sequentialAnimation(); // Execute sequential animation
} else if (switchState_3 == LOW) { // If the switch is not pressed (HIGH state)
sasaAnimation(); // Execute sequential animation
}
delay(50);
}
// Swipe animation function
void swipeAnimation() {
fill_solid(&leds[16], 16, CRGB::Red);
for (int i = 0; i < 9; i++) {
leds[i] = CRGB(255, 132, 0); // Orange color
FastLED.show();
digitalWrite(Led_tl, HIGH); // Turn off the current LED
delay(DELAY_TIME);
digitalWrite(Led_tl, LOW);
}
if (analogRead(drifbu) == LOW) {
digitalWrite(Led_dri, HIGH);
}
else {
digitalWrite(Led_dri, LOW);
}
FastLED.clear();
// Show animation on LEDs 32 and 17
}
// Sequential animation function
void sequentialAnimation() {
fill_solid(&leds[0], 16, CRGB::Red);
for (x = 31; x >= 24; x--) {
leds[16] = CRGB(255, 132, 0);
leds[x % NUM_LEDS] = CRGB(255, 132, 0);
FastLED.show();
digitalWrite(Led_tr, HIGH);
delay(DELAY_TIME);
digitalWrite(Led_tr, LOW);
}
if (x == 17) {
x = 32;
}
if (analogRead(drifbu) == LOW) {
digitalWrite(Led_dri, HIGH);
}
else {
digitalWrite(Led_dri, LOW);
}
FastLED.clear();
}
void sasaAnimation () {
delay(100);
fill_solid(&leds[0], 16, CRGB::Red);
fill_solid(&leds[16], 16, CRGB::Red);
FastLED.show();
}