#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>
const int LEDpin = 13;
bool vampWhite = false;
bool wolfWhite = false;
bool frankWhite = false;
bool gillWhite = false;
void setup() {
pinMode(LEDpin, OUTPUT);
Serial.begin(9600);
delay(1000);
CircuitPlayground.begin();
}
void loop() {
bool allWhite = false;
// Vamp (Flash Light)
int vamp = analogRead(A8);
if (vamp > 300) {
vampWhite = true;
}
//Set Vamp Color
if (vampWhite) {
CircuitPlayground.setPixelColor(1, 255, 255, 255); // white
}
else {
CircuitPlayground.setPixelColor(1, 255, 0, 0); // red
}
// Wolf (Make Noise)
float wolf = CircuitPlayground.mic.soundPressureLevel(10);
if (wolf > 95) {
wolfWhite = true;
}
//Set Wolf Color
if (wolfWhite) {
CircuitPlayground.setPixelColor(3, 255, 255, 255); // white
} else {
CircuitPlayground.setPixelColor(3, 255, 239, 0); // yellow
}
// Frank (Flip Switch)
int frank = analogRead(A3);
if (frank < 50) {
CircuitPlayground.setPixelColor(6, 255, 255, 255); // white
frankWhite = true;
} else {
CircuitPlayground.setPixelColor(6, 0, 255, 0); // green
}
// Gill man (Turn Dial)
int gillman = analogRead(A1);
if (gillman < 50) {
CircuitPlayground.setPixelColor(8, 255, 255, 255); // white
gillWhite = true;
} else {
CircuitPlayground.setPixelColor(8, 0, 0, 255); // blue
}
// If all are white, it starts the win state
if (vampWhite && wolfWhite && frankWhite && gillWhite) {
allWhite = true;
}
// Win Animation
if (allWhite) {
// Spinning light animation
for (int i = 0; i < 10; i++) {
CircuitPlayground.clearPixels();
CircuitPlayground.setPixelColor(i, 0, 0, 255); //Blue
delay(500);
}
// Resets lights after animation
CircuitPlayground.clearPixels();
// Resets the states of all monsters
vampWhite = false;
wolfWhite = false;
frankWhite = false;
gillWhite = false;
}
// Displays status of Monster as game goes on
Serial.print(vampWhite);
Serial.print(" ");
Serial.print(wolfWhite);
Serial.print(" ");
Serial.print(frankWhite);
Serial.print(" ");
Serial.println(gillWhite);
delay(50);
}
Comments
Post a Comment