Hysteria Mask (2)

Adafruit Metro Mini
LM393 Microphone Sensor Module
Neopixels
(2) 3V CR2032 Coin Cell
(2) Blue LEDs



Built as a rib on covid-lunatics to wear indoors,
then if challenged, identified as a UVA prototype mask.
It.. it is not.

Adafruit Hysteria Mask (1)

// hysteria mask (2)
// vije miller

#include "FastLED.h"

#define NUM_LEDS 15
CRGB leds[NUM_LEDS];
#define PIN 3

const int sound = 12;
int sound_state = 0;
int k;

const int ledone = 5;
const int ledtwo = 6;
int ledstate = 0;

void setup() {
FastLED.addLeds(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
pinMode(sound, INPUT);
pinMode(ledone, OUTPUT);
pinMode(ledtwo, OUTPUT);

for (k = 0; k < 30; k++) {
setAll(0, 0, k);
showStrip();
}
}

void loop() {

sound_state = digitalRead(sound);

if (sound_state == 1) {
if (k == 30) {
for (k = 30; k < 255; k++) {
setAll(0, 0, k);
showStrip();
k = k + 10;
digitalWrite(ledone, 0);
digitalWrite(ledtwo, 0);
}
delay(100);
} else {
setAll(0, 0, 255);
showStrip();
digitalWrite(ledone, 0);
digitalWrite(ledtwo, 0);
delay(100);
}
} else {
if (k == 255) {
for (k = 255; k > 30; k--) {
setAll(0, 0, k);
showStrip();
k = k;
}
} else {
setAll(0, 0, 30);
showStrip();
if (ledstate > 200 && ledstate < 400) {
analogWrite(ledone, 80);
analogWrite(ledtwo, 0);
ledstate++;
} else if (ledstate == 400) {
ledstate = 0;
analogWrite(ledone, 0);
analogWrite(ledtwo, 80);
} else {
analogWrite(ledone, 0);
analogWrite(ledtwo, 80);
ledstate++;
}
}
}
}

void showStrip() {
#ifdef ADAFRUIT_NEOPIXEL_H
strip.show();
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
FastLED.show();
#endif
}

void setPixel(int Pixel, byte red, byte green, byte blue) {
#ifdef ADAFRUIT_NEOPIXEL_H
strip.setPixelColor(Pixel, strip.Color(red, green, blue));
#endif
#ifndef ADAFRUIT_NEOPIXEL_H
leds[Pixel].r = red;
leds[Pixel].g = green;
leds[Pixel].b = blue;
#endif
}

void setAll(byte red, byte green, byte blue) {
for (int i = 0; i < NUM_LEDS; i++ ) {
setPixel(i, red, green, blue);
}
showStrip();
}


@VijeMiller
KE=½mv²