Pith - adafruit_hysteria_mask
adafruit_hysteria_mask/adafruit_hysteria_mask_1.ino [1.4 kb]
Modified: 17:35:46 58 026 (16 May 026)
14 Days Ago
// hysteria mask
// vgmlr
#include "FastLED.h"
#define NUM_LEDS 3
CRGB leds[NUM_LEDS];
#define PIN 13
int fade_state = 0;
const int sound = 12;
const int mouth = 11;
int sound_state = 0;
void setup() {
  FastLED.addLeds< WS2812, PIN, GRB >(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
  pinMode(sound, INPUT);
  pinMode(mouth, OUTPUT);
  digitalWrite(mouth, LOW);
  delay(2000);
}
void loop() {
  if (fade_state == 0) {
    fadein(0x00, 0x00, 0xff);
    fade_state = 1;
  }
  sound_state = digitalRead(sound);
  if (sound_state == 1) {
    digitalWrite(mouth, HIGH);
  } else {
    digitalWrite(mouth, LOW);
  }
}
void fadein(byte red, byte green, byte blue) {
  float r, g, b;
  for (int k = 0; k < 256; k = k + 1) {
    r = (k / 256.0) * red;
    g = (k / 256.0) * green;
    b = (k / 256.0) * blue;
    setAll(r, g, b);
    showStrip();
    delay(5);
  }
}
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();
}
Updates
Shim - Android 70.026.1
Wedge - Linux 68.026.1
Wedge - Android 68.026.1
Taper - Linux 64.026.1
Ayh Extension - Chrome 63.026.1
Dev
TVShow (227) 'CSA'
TVShow (228) 'APT'
TVProgram (83) 'BXT'
Miter Update(s)
Shim (Dictation)

Menu
Calendar
Project Tin (024/029)
Miter
RSS Feed
User Avatar
@vgmlr
=SUM(parts)