Loaded Every Thing From My Work

This commit is contained in:
ghassan committed 2020-01-28 08:42:25 +03:00
1 parent 4d81b2687b
commit 3229659f4e
176 files changed
+9623

No files matched your search

@@ -0,0 +1,29 @@
//======================================================
// TERMINAL WINDOW - NATIVE USB
//======================================================
void terminal(String msg)
{
msg += "\n";
Terminal.print(msg);
}
//======================================================
// BLUETOOTH WINDOW - NATIVE/VERTUAL USB
//======================================================
void bluetooth(String msg)
{
msg += "\n";
Bluetooth.print(msg);
}
//======================================================
// BLUETOOTH WINDOW - NATIVE/VERTUAL USB
//======================================================
void dualcomm(String msg)
{
terminal(msg);
bluetooth(msg);
}
+137
View File
@@ -0,0 +1,137 @@
//======================================================
// MAIN COUNTER GAME LOOP
//======================================================
/* COUNTER GAME SETTINGS PARAMETERS NOTE:
* --------------------------------------
*
* FORMAT :
* --------
* {"le": false, "lm": 10}
*
* MEANNING :
* ----------
* ct : count
* le : stands for limit enable, if is TRUE the game end if target value is meet
* lm : targeted amount of kicks
*
* THINGS THAT ENDS THE GAME :
* ---------------------------
* 1. BY A COMMAND "FROM APP VIA BLUETOOTH"
* 2. BY LIMITS MEET "WHEN NUMBER OF YOUR KICKS REACH TO lm VALUE"
*
* WHAT JSON TO BE COLLECTED :
* ---------------------------
* 1. FOR EVERY KICK YOU RECEIVE THE COUNTER DISJSON AND TIMESTAMP
* WE NEED TO COLLECT TIMESTAMPS AS AN ARRAY IN JSON FORMAT
*
* CALCULATING RESULTS :
* ---------------------
* No calculation required, Its directly the count
*/
void game_counter(String settings)
{
//------------------------------------------------------
// START OF READING THE SETTINGS
//------------------------------------------------------
// Deserialize the JSON document
DeserializationError error = deserializeJson(JSON, settings); // the main JSON body container
// JSON ERROR
if(error) {
dualcomm(JSON_ERROR);
return;
}
// PUBLIC VARIABLES
uint16_t limit = JSON["lm"]; // Kick Target Limit
bool limitEnable = JSON["le"]; // Enable Kick Target Limit
// Clearing Buffer
JSON.clear();
// Trying To Delete The Document
//JSON.delete();
// Kick Counter
uint16_t counter = 0;
// Game Start Lights
LED_SIGNAL_START();
//------------------------------------------------------
// PREPARE FOR GAME START
//------------------------------------------------------
// staring Of time stamp
unsigned long startStamp = millis();
while(1)
{
// Time Stamp
unsigned long timeStamp = millis() - startStamp;
// If Stop Command Came From Smart Phone
if(isBluetooth)
{
String msg = Bluetooth.readStringUntil('\n');
msg.trim();
if(msg == CM_STOP)
{
dualcomm(GAME_OVER);
// Grean Light In
LED_SIGNAL_END();
// RESET
return;
}
else if(msg == CM_RESET)
{
counter = 0;
startStamp = millis();
timeStamp = startStamp;
LED_SIGNAL_RESET();
}
}
// If Limits Are Enabled And Meet
if(limitEnable == true && counter == limit)
{
// END GAME
dualcomm(GAME_OVER);
// Celebration
LED_SIGNAL_CELEBRATION();
// RESET
return;
}
// Read Impact
if(readImpact() > VTH)
{
counter++;
dualcomm(counter_JSON_json(counter, timeStamp));
delay(100);
}
}
}
//======================================================
// COUNTER JSON JSON -> To Send Back To Server
//======================================================
String counter_JSON_json(unsigned int ct, unsigned int st)
{
// Convert Int To Float
float stamp = st;
stamp /= 1000;
// Assignning JSONset
JSON["ct"] = ct;
JSON["st"] = String(stamp, 3).toFloat();
String output;
serializeJson(JSON, output);
JSON.clear();
return output;
}
@@ -0,0 +1,203 @@
//======================================================
// REACTION GAME MAIN ROUTINE
//======================================================
/* REACTION GAME SETTINGS PARAMETERS NOTE:
* ------------------------------------------
*
* FORMAT :
* --------
* {"tr": 10, "mn": 1, "mx": 2}
*
* MEANNING :
* ----------
* tr : trials pre counter
* mn : minimum delay, between trials
* mx : maximum delay, between trials
*
* THINGS THAT ENDS THE GAME :
* ---------------------------
* 1. BY COUNT DOWN "tr" REACH TO ZERO
* 2. BY A COMMAND "FROM APP VIA BLUETOOTH"
*
* CALCULATING RESULTS :
* ---------------------
* Rapid Kick Speed = Number Of Kickes Made / Elasped Time In Sec
*/
//======================================================
void game_reaction(String settings)
{
//------------------------------------------------------
// START OF READING THE SETTINGS
//------------------------------------------------------
// Deserialize the JSON document
DeserializationError error = deserializeJson(JSON, settings);
// JSON ERROR
if(error) {
dualcomm(JSON_ERROR);
return;
}
// PUBLIC VARIABLES
uint8_t minDelay = JSON["mn"];
uint8_t maxDelay = JSON["mx"];
uint16_t trials = JSON["lm"];
uint16_t temp = trials;
// Fix Random Error
maxDelay += 1;
// Clearing Buffer
JSON.clear();
//------------------------------------------------------
// PREPARE FOR GAME START
//------------------------------------------------------
// DisJSON Welcome Message
terminal("");
terminal("trials : " + String(trials) + " Strikes");
terminal("minDelay : " + String(minDelay) + " Seconds");
terminal("maxDelay : " + String(maxDelay) + " Seconds");
terminal("2 Seconds To Start Get Ready & Good Luck !!");
terminal("");
// Ready Signal
LED_SIGNAL_REACTION_START();
// Main Variables
uint16_t sdelay = 0;
uint16_t power = 0;
uint16_t response = 0;
unsigned long startTime = 0;
unsigned long stopTime = 0;
// Processing Results
for(int i=0; i<trials; i++)
{
// Reading Kick JSON
terminal(" ------ Trial Number (" + String(i + 1) + ") ------");
terminal(" -> Get Ready !!");
// Set Random Delay Time
sdelay = random(minDelay, maxDelay);
sdelay *= 1000;
delay(sdelay);
// Light Up Green
LED_SET_COLOR(0, 255, 0, 255);
// Start Timer
startTime = millis();
// Sensing Strike Power
while(power < VTH)
{
// Reading The Strike
power = readImpact();
// If Stop Command Came From Smart Phone
if(isBluetooth)
{
String msg = Bluetooth.readStringUntil('\n');
msg.trim();
if(msg == CM_STOP) {
dualcomm(GAME_OVER);
// LightUp
LED_SIGNAL_END();
// RESET
return;
}
else if(msg == CM_RESET) {
LED_SIGNAL_REACTION_RESET();
trials = temp;
break;
}
}
}
// Stop Timer
stopTime = millis();
// Stop Light
LED_SET_COLOR(255, 0, 0, 255);
// Calculating Response Time
response = stopTime - startTime - 1;
// Create Json JSON
String msg = reaction_JSON_json(i+1, power, response, sdelay);
// Print To Terminal
dualcomm(msg);
// Clear All
sdelay = 0;
power = 0;
response = 0;
}
// Red Light Delay
delay(500);
// END GAME
dualcomm(GAME_OVER);
// Blink Red
LED_SIGNAL_CELEBRATION();
// Return To Game Selector
return;
}
//======================================================
// REACTION JSON JSON -> To Send Back To Server
//======================================================
String reaction_JSON_json(unsigned int count, unsigned int power, unsigned int response, unsigned int startDelay)
{
// Convert To Seconds Unit
float re = response;
re /= 1000;
// Asignning Values
JSON["ct"] = count; // Strike Number
JSON["pw"] = power; // Strike Power In Analog Read
JSON["sd"] = startDelay/1000; // LED Strip Start Delay in Seconds
JSON["re"] = String(re, 3).toFloat(); // Strike Reaction Time In Milli Sec
String output;
serializeJson(JSON, output);
JSON.clear();
return output;
}
//======================================================
// REACTION GAME START LED SIGNAL
//======================================================
void LED_SIGNAL_REACTION_START()
{
// Cross fade the white signal to get ready
LED_CROSS_FADE(255, 255, 255, 3);
// Set the LED strip color to red
LED_SET_COLOR(255, 0, 0, 255);
}
//======================================================
// REACTION GAME RESET LED SIGNAL
//======================================================
void LED_SIGNAL_REACTION_RESET()
{
// Light Bright Blue
LED_BLINK(0, 0, 255, 2);
// Wait For 1/4 Second
delay(250);
// Fade Out The Blue
LED_SET_COLOR(0, 255, 0, 255);
}
@@ -0,0 +1,37 @@
//======================================================
// MAIN PROGRAM LOOP
//======================================================
/* game selector is the main function that tell the game groutine
* which game to be JSONed and at what parameters
*/
void game_selector(String game, String settings)
{
// Kick Counter Game
if(game == "ct") {
terminal(GM_COUNTER);
game_counter(settings);
return;
}
// Time Attack Game
else if(game == "ta") {
terminal(GM_TATTACK);
game_timeAttack(settings);
return;
}
// Time Attack Game
else if(game == "ra") {
terminal(GM_REACTION);
game_reaction(settings);
return;
}
// Unknown Game
else {
dualcomm(UNKNOWN_GAME);
return;
}
}
@@ -0,0 +1,184 @@
//======================================================
// TIME ATTACK GAME MAIN ROUTINE
//======================================================
/* TIME ATTACK GAME SETTINGS PARAMETERS NOTE:
* ------------------------------------------
*
* FORMAT :
* --------
* {"tm": 10, "le": false, "lm": 10}
*
* tm : count down timer starting value
* le : stands for limit enable, if is TRUE the game end if target value is meet
* lm : targeted amount of kicks
*
* THINGS THAT ENDS THE GAME :
* ---------------------------
* 1. BY COUNT DOWN "tm" REACH TO ZERO
* 2. BY A COMMAND "FROM APP VIA BLUETOOTH"
* 3. BY LIMITS MEET "WHEN NUMBER OF YOUR KICKS REACH TO lm VALUE"
*
* CALCULATING RESULTS :
* ---------------------
* Rapid Kick Speed = Number Of Kickes Made / Elasped Time In Sec
* Delay Between Kicks = Time Of Current Kick - Time Of Last Kick
*
* RETURNNING JSON FORMAT :
* ------------------------
* {"tm" : 82, "ct" : 10, "dl" : 1234, "st" : 585}
*
* tm : timer count in Sec
* ct : strike counter (number of kicks)
* dl : delay between strikes
* st : time stampe of the strike in milli Seconds
*/
void game_timeAttack(String settings)
{
//------------------------------------------------------
// START OF READING THE SETTINGS
//------------------------------------------------------
// Deserialize the JSON document
DeserializationError error = deserializeJson(JSON, settings); // the main JSON body container
// JSON ERROR
if(error) {
dualcomm(JSON_ERROR);
return;
}
// PUBLIC VARIABLES
uint16_t time = JSON["tm"]; // Time Window To JSON
uint16_t timer = time;
uint16_t limit = JSON["lm"]; // Kick Target Limit
bool limitEnable = JSON["le"]; // Enable Kick Target Limit
// Clearing Buffer
JSON.clear();
//------------------------------------------------------
// PREPARE FOR GAME START
//------------------------------------------------------
// Send Initial DisJSON
dualcomm(timeAttack_JSON_json(timer, 0, 0, 0));
// Start LED Signal
LED_SIGNAL_START();
// Building Timers 1000mSec -> 1Sec
TimeTrigger sec_tick(1000);
// Kick Counter
uint16_t counter = 0;
// staring Of time stamp
unsigned long startStamp = millis();
// store the time of the previous kick
unsigned long lastStamp = 0;
// reseting time ticker
sec_tick.Reset();
// While The Game Is Still On
while(timer != 0)
{
// Time Stamp
unsigned long timeStamp = millis() - startStamp;
// If Stop Command Came From Smart Phone
if(isBluetooth)
{
String msg = Bluetooth.readStringUntil('\n');
msg.trim();
if(msg == CM_STOP)
{
dualcomm(GAME_OVER);
// Grean Light In
LED_SIGNAL_END();
// Return
return;
}
else if(msg == CM_RESET)
{
timer = time;
counter = 0;
startStamp = millis();
timeStamp = startStamp;
lastStamp = timeStamp;
sec_tick.Reset();
dualcomm(timeAttack_JSON_json(timer, counter, lastStamp, timeStamp));
LED_SIGNAL_RESET();
}
}
// Every Kick ---------------------------->>>
if(readImpact() > VTH)
{
counter++;
dualcomm(timeAttack_JSON_json(timer, counter, lastStamp, timeStamp));
lastStamp = timeStamp;
delay(100);
}
// Every Second ---------------------------->>>
if(sec_tick.Trigger())
{
timer--;
dualcomm(timeAttack_JSON_json(timer, counter, 0, 0));
}
// If Limits Are Enabled And Meet
if(limitEnable == true && counter == limit)
{
// END GAME
dualcomm(GAME_OVER);
// Celebrate
LED_SIGNAL_CELEBRATION();
// Return
return;
}
}
// Send End Game Signal To Smart Phone
dualcomm(GAME_OVER);
// LightUp
LED_FADEIN(255, 0, 0); // RED Color
delay(2000); // Delay 2000
LED_CLEAR(); // CLEAR OFF
// Return
return;
}
//======================================================
// TIME ATTACK KICK JSON JSON -> To Send Back To Server
//======================================================
String timeAttack_JSON_json(unsigned int RunningTime, unsigned int KickCount, unsigned int LastStamp, unsigned int TimeStamp)
{
// Building The Buffer
JSON["tm"] = RunningTime;
JSON["ct"] = KickCount;
// Calculations
if(TimeStamp > 0)
{
// Calculate Time Stamp In Seconds
float st = TimeStamp;
st /= 1000;
JSON["st"] = String(st, 3).toFloat();
// Calculate Strike Delay In Seconds
float dl = TimeStamp - LastStamp;
dl /= 1000;
JSON["dl"] = String(dl, 3).toFloat();
}
String output;
serializeJson(JSON, output);
JSON.clear();
return output;
}
+197
View File
@@ -0,0 +1,197 @@
//======================================================
// LIBRARIES
//======================================================
#include <ArduinoJson.h>
#include <TimeTrigger.h>
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
#include <avr/power.h>
#endif
//======================================================
// JSON STRINGS AND DOCUMENT
//======================================================
// FIXED MESSAGES
#define POWERUP "{\"status\":\"POWER UP\"}"
#define UNDERSTOOD "{\"status\":\"OK\"}"
#define JSON_ERROR "{\"status\":\"ERROR JSON\"}"
#define TARGET_MET "{\"status\":\"TARGET MEET\"}"
#define GAME_OVER "{\"status\":\"GAME OVER\"}"
#define TIME_OVER "{\"status\":\"TIME OVER\"}"
#define UNKNOWN_GAME "{\"status\":\"UNKNOWN GAME\"}"
// GAME NAMES
#define GM_COUNTER "{\"gm\":\"COUNTER\"}"
#define GM_TATTACK "{\"gm\":\"TIME ATTACK\"}"
#define GM_REACTION "{\"gm\":\"REACTION\"}"
#define GM_DECISION "{\"gm\":\"DECISION\"}"
#define GM_STAMINA "{\"gm\":\"STAMINA\"}"
// COMMAND LIST
#define CM_START "{\"cm\":\"START\"}"
#define CM_RESET "{\"cm\":\"RESET\"}"
#define CM_STOP "{\"cm\":\"STOP\"}"
#define CM_EXIT "{\"cm\":\"EXIT\"}"
// JSON CAPACITY
#define CAPACITY 100
// Public JSON Document
DynamicJsonDocument JSON(CAPACITY); // Building JSON Buffer
//======================================================
// HARDWARE SETUP & SELECTION
//======================================================
// Arduino Hardware Serial Port
#define Terminal Serial // SERIAL PORT USED AS TERMINAL WINDO FOR DEBUG
// The Integer Value Of The Strike Is Exceeded Accept As A Point
#define VTH 14 // THRESHOLD VOLTAGE FOR ZERO POSITIONNING KICKING POWER SENSOR
// Number Of LED's In The Neo Pixel Strip
#define NUM_PIXELS 14 // NUMBER OF LED'S IN NEO PIXEL STRIP
// Incase You Are Using Arduino MEGA
#ifdef ARDUINO_AVR_MEGA2560
#define Bluetooth Serial1 // We will Connect The HC-05 To Hardware Serial1 In Arduino Mega
#define LED_STRIP 53 // LED STRIP PIN NUMBER
#define SENSOR_PIN A0 // IMPACT SENSOR
#define RANDOM_SOURCE A7 // RANDOM NUMBER GENERATOR SOURCE
// Incase You Are Using Arduino Nano
#elif ARDUINO_AVR_UNO || ARDUINO_AVR_NANO
//----------------------------------------------------------
/* ARDUINO NANO DOESNOT HAVE A SECOND NATIVE
SERIAL PORT SO WE USE SOFTWARE SERIAL LIBRARY */
#include <SoftwareSerial.h>
//----------------------------------------------------------
SoftwareSerial Bluetooth(10, 11); // Pin 10 RX, Pin 11 TX
#define LED_STRIP 2 // LED STRIP PIN NUMBER
#define SENSOR_PIN A0 // IMPACT SENSOR
#define RANDOM_SOURCE A4 // RANDOM NUMBER GENERATOR SOURCE
// if This Was The ESP32 Core
#elif ESP32
//----------------------------------------------------------
#include <BluetoothSerial.h>
#if !defined(CONFIG_BT_ENABLED) || !defined(CONFIG_BLUEDROID_ENABLED)
#error Bluetooth is not enabled! Please run `make menuconfig` to and enable it
#endif
//----------------------------------------------------------
BluetoothSerial Bluetooth; // Here We Use the Native Bluetooth In The ESP32
#define LED_STRIP 33 // LED STRIP PIN NUMBER
#define SENSOR_PIN 39 // IMPACT SENSOR
#define RANDOM_SOURCE 34 // RANDOM NUMBER GENERATOR SOURCE
// End Of Arduino Selection ARDUINO_MEGA
#endif
// NEO PIXEL STRIP
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, LED_STRIP, NEO_GRB + NEO_KHZ800);
//======================================================
// DEFINITION & DECLERATIONS
//======================================================
// Serial Flags
#define isBluetooth Bluetooth.available()
#define isTerminal Terminal.available()
//======================================================
// READING IMPACT POWER FROM ANALOG PINS
//======================================================
// READING THE IMPACT
int readImpact()
{
int value = analogRead(SENSOR_PIN);
return value;
}
//======================================================
// MAIN HARDWARE SETUP
//======================================================
void setup()
{
// Communications
Terminal.begin(9600);
// Make Sure Of The Core
#ifdef ESP32
Bluetooth.begin("KICKER"); //Bluetooth device name
#else
Bluetooth.begin(9600);
#endif
// I/O
pixels.begin(); // Neo Pixel
LED_CLEAR(); // Turn Off All LED
// The Random Number Source
randomSeed(analogRead(RANDOM_SOURCE));
// POWER UP MESSGAE
dualcomm(POWERUP);
// DISPLAY COMPANY COUNTRY FLAG
LED_BAHRAIN_FLAG(); // Bahrain Flag
LED_COLOMBIA_FLAG(); // Colombia Flag
// DisJSON Rainbow
LED_CLEAR();
}
//======================================================
// MAIN PROGRAM LOOP
//======================================================
void loop()
{
// Reading From Bluetooth
if(Bluetooth.available())
{
// Reading Message From Bluetooth
String msg = Bluetooth.readStringUntil('\n');
msg.trim();
// DisJSON On Sertial
terminal(msg);
// Deserialize the JSON document
DeserializationError error = deserializeJson(JSON, msg);
// If The System Understood The Message Clearly
if(!error)
{
// Sending Status Message
dualcomm(UNDERSTOOD);
// Reading Game Name & Settings
String game = JSON["gm"];
String settings = JSON["set"];
// Clearing JSON Buffer
JSON.clear();
// Entering To Game Selector
game_selector(game, settings);
}
else
{
terminal(JSON_ERROR);
}
Bluetooth.flush();
}
}
//======================================================
// END OF PROGRAM
//======================================================
+244
View File
@@ -0,0 +1,244 @@
#define BETWEEN_FADE 15
#define FADE_RATE 15
#define BLINK_RATE 250
//------------------------------------------------------
// BLINK
//------------------------------------------------------
void LED_BLINK(uint8_t R, uint8_t G, uint8_t B, int Times)
{
for(int i=0; i<Times; i++)
{
LED_SET_COLOR(R, G, B, 255);
delay(BLINK_RATE);
LED_CLEAR();
delay(BLINK_RATE);
}
}
//------------------------------------------------------
// COLOR WHIPE
//------------------------------------------------------
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait)
{
for(uint16_t i=0; i<NUM_PIXELS; i++)
{
pixels.setPixelColor(i, c);
pixels.show();
delay(wait);
}
}
//------------------------------------------------------
// END GAME LIGHTING SIGNAL
//------------------------------------------------------
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait)
{
uint16_t i, j;
for(j=0; j<256*5; j++)
{ // 5 cycles of all colors on WHEEL
for(i=0; i< pixels.numPixels(); i++)
{
pixels.setPixelColor(i, WHEEL(((i * 256 / pixels.numPixels()) + j) & 255));
}
pixels.show();
delay(wait);
}
}
//------------------------------------------------------
// END GAME LIGHTING SIGNAL
//------------------------------------------------------
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t WHEEL(byte WHEELPos)
{
WHEELPos = 255 - WHEELPos;
if(WHEELPos < 85)
{
return pixels.Color(255 - WHEELPos * 3, 0, WHEELPos * 3);
}
if(WHEELPos < 170)
{
WHEELPos -= 85;
return pixels.Color(0, WHEELPos * 3, 255 - WHEELPos * 3);
}
WHEELPos -= 170;
return pixels.Color(WHEELPos * 3, 255 - WHEELPos * 3, 0);
}
//------------------------------------------------------
// Set LED Brightness
//------------------------------------------------------
void LED_SET_BRIGHTNESS(uint8_t Value)
{
pixels.setBrightness(Value);
}
//------------------------------------------------------
// Set LED Color
//------------------------------------------------------
void LED_SET_COLOR(uint8_t R, uint8_t G, uint8_t B, uint8_t Intensity)
{
// Set Intensity
LED_SET_BRIGHTNESS(Intensity);
// Loop
for(int i=0; i<NUM_PIXELS; i++)
{
pixels.setPixelColor(i, pixels.Color(R, G, B));
}
pixels.show();
}
//------------------------------------------------------
// Set Color Fade In
//------------------------------------------------------
void LED_FADEIN(uint8_t R, uint8_t G, uint8_t B)
{
for(int i=0; i<=255; i++)
{
pixels.setBrightness(i);
for(int j=0; j<NUM_PIXELS; j++)
{
pixels.setPixelColor(j, pixels.Color(R, G, B));
}
pixels.show();
delay(4);
}
}
//------------------------------------------------------
// Set Color Fade Out
//------------------------------------------------------
void LED_FADEOUT(uint8_t R, uint8_t G, uint8_t B)
{
for(int i=255; i>=0; i--)
{
pixels.setBrightness(i);
for(int j=0; j<NUM_PIXELS; j++)
{
pixels.setPixelColor(j, pixels.Color(R, G, B));
}
pixels.show();
delay(4);
}
}
//------------------------------------------------------
// Set LED Color Cross Fade
//------------------------------------------------------
void LED_CROSS_FADE(uint8_t R, uint8_t G, uint8_t B, unsigned int Times)
{
for(int i=0; i<Times; i++) {
LED_FADEIN(R, G, B);
LED_FADEOUT(R, G, B);
delay(BETWEEN_FADE);
}
}
//------------------------------------------------------
// Clearing The LED Strip
//------------------------------------------------------
void LED_CLEAR()
{
// Clear The Strip Color
pixels.clear();
// Show The Change
pixels.show();
}
//======================================================
// REACTION GAME START LED SIGNAL
//======================================================
void LED_SIGNAL_START()
{
// Cross Fade White Color To Get ready 3 Times
LED_CROSS_FADE(255, 255, 255, 3);
// Set Strip Color Green
LED_SET_COLOR(0, 255, 0, 255);
}
//======================================================
// REACTION GAME END SINGNAL LED SIGNAL
//======================================================
void LED_SIGNAL_END()
{
// Blink Red Twice
LED_BLINK(255, 0, 0, 2);
// Fade The Red Color To Nothing
LED_FADEOUT(255, 0, 0);
}
//======================================================
// REACTION GAME START LED CELEBRATION
//======================================================
void LED_SIGNAL_CELEBRATION()
{
// Display Rainbow Twice
rainbowCycle(2);
// Grean Light OUT
LED_FADEOUT(0, 255, 0);
}
//======================================================
// REACTION GAME RESET LED SIGNAL
//======================================================
void LED_SIGNAL_RESET()
{
// Light Bright Blue
LED_BLINK(0, 0, 255, 2);
// Wait For 1/4 Second
delay(250);
// Fade Out The Blue
LED_SET_COLOR(0, 255, 0, 255);
// Set Strip Color Green
LED_SET_COLOR(0, 255, 0, 255);
}
//======================================================
// DISPLAY BAHRAIN FLAG
//======================================================
void LED_BAHRAIN_FLAG()
{
LED_SET_BRIGHTNESS(255);
colorWipe(pixels.Color(255, 255, 255), 30); // White
delay(250);
colorWipe(pixels.Color(255, 0, 0), 30); // Red
delay(250);
LED_FADEOUT(255, 0, 0);
}
//======================================================
// DISPLAY COLOMBIA FLAG
//======================================================
void LED_COLOMBIA_FLAG()
{
LED_SET_BRIGHTNESS(255);
colorWipe(pixels.Color(255, 255, 0), 30); // Yellow
delay(250);
colorWipe(pixels.Color(0, 0, 255), 30); // Blue
delay(250);
colorWipe(pixels.Color(255, 0, 0), 30); // Red
delay(250);
LED_FADEOUT(255, 0, 0);
}