Skip to content

Instantly share code, notes, and snippets.

@melPlett
Created June 1, 2018 20:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Embed
What would you like to do?
#include <AlaLedRgb.h>
AlaLedRgb Lv1;
AlaLedRgb Lv2;
AlaLedRgb Lv3;
AlaSeq Light1[] =
{
{ ALA_OFF, 100, 100, alaPalNull },
{ ALA_GLOW, 2000, 2000, alaPalCool },
{ ALA_OFF, 100, 100, alaPalNull },
{ ALA_ENDSEQ }
};
AlaSeq Light2[] =
{
{ ALA_OFF, 100, 100, alaPalNull },
{ ALA_GLOW, 2000, 2000, alaPalRgb },
{ ALA_OFF, 100, 100, alaPalNull },
{ ALA_ENDSEQ }
};
AlaSeq Light3[] =
{
{ ALA_OFF, 100, 100, alaPalNull },
//{ ALA_ON, 1000, 2000, alaPalRgb },
{ ALA_SPARKLE, 1000, 1000, alaPalFire },
{ ALA_OFF, 100, 100, alaPalNull },
{ ALA_ENDSEQ }
};
int sensor;
int score;
int reset;
void setup() {
Serial.begin(9600);
score = 0;
reset = 0;
Lv1.initWS2812(40, 3);
Lv2.initWS2812(40, 3);
Lv3.initWS2812(40, 3);
Lv1.setBrightness(0x444444);
Lv2.setBrightness(0x444444);
Lv3.setBrightness(0x444444);
Lv1.setAnimation(Light1);
Lv2.setAnimation(Light2);
Lv3.setAnimation(Light3);
}
void loop() {
sensor = analogRead(A0);
//Serial.print("light= ");
//Serial.println(sensor);
if (sensor < 5 ) {
score = (score + 1);
delay(500);
}
//Serial.print("score: ");
//Serial.println(score);
if (score < 5) {
Lv1.runAnimation();
}
if (score >= 5 && score < 10) {
Lv2.runAnimation();
}
if (score >= 10 && score < 20) {
Lv3.runAnimation();
}
if(score == 20){
score = reset;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment