-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8c03700
commit 598a562
Showing
1 changed file
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#include <Arduino.h> | ||
#include <FastLED.h> | ||
|
||
#define LEDpin 5 | ||
#define LEDnumber 22 | ||
|
||
CRGB leds[LEDnumber]; | ||
|
||
void flashMagenta(); | ||
void halfColours(); | ||
void showState(string currentState); | ||
|
||
void setup(){ | ||
Serial.begin(9600); | ||
FastLED.addLeds<WS2812, LEDpin,GRB>(leds, LEDnumber); | ||
pinMode(LEDpin,OUTPUT); | ||
} | ||
|
||
void loop(){ | ||
//if intaking | ||
flashMagenta(); | ||
|
||
} | ||
|
||
void flashMagenta(){ | ||
for(i=0; i<=LEDnumber; i++){ | ||
leds[i] = CRGB(255,0,255); | ||
} | ||
static unsigned long magentaMillis = millis(); | ||
if (millis() - magentaMillis > 50){ | ||
digitalWrite(magentaMillis,!digitalRead(LEDpin)); | ||
magentaMillis = millis(); | ||
} | ||
} | ||
void halfColours(){//half the leds with red and blue | ||
for (i=0; i<=LEDnumber/2;i++){ | ||
leds[i] = CRGB(255,0,0); | ||
leds[i + LEDnumber/2]=CRGB(0,0,255); | ||
} | ||
delay(wait); | ||
FastLED.show(); | ||
} | ||
|
||
//swapping states | ||
enum class LEDstates : uint8_t | ||
{ | ||
HALF, | ||
FLASHING, | ||
PULSING, | ||
} | ||
|
||
static LEDstates currentState = LEDstates::HALF; | ||
|
||
switch(currentState){ | ||
case LEDstates::HALF: | ||
showState("HALF STATE"); | ||
//if intaking{currentState = LEDstates::FLASHING} | ||
break; | ||
|
||
case LEDstates::FLASHING: | ||
showState("FLASHING STATE"); | ||
//if | ||
break; | ||
} | ||
|
||
void showState(String currentState){ | ||
static String previousState = ""; | ||
|
||
if(currentState!= previousState) | ||
{ | ||
Serial.print(currentState); | ||
previousState = currentState; | ||
} | ||
} |