// Because conditional #includes don’t work w/Arduino sketches…
#include <SPI.h> // COMMENT OUT THIS LINE FOR GEMMA OR TRINKET
//#include <avr/power.h> // ENABLE THIS LINE FOR GEMMA OR TRINKET
#define N_PIXELS 9 // Number of pixels you are using
#define MIC_PIN A0 // Pressure sensor here
#define DATAPIN 6
#define BRIGHTNESS 200
#define FRAMES_PER_SECOND 30
int lvl = 10;
int soundLevel;
CRGB leds[N_PIXELS];
CRGBPalette16 gPal;
const TProgmemPalette16 Engine_p PROGMEM =
{
CRGB::Purple,
CRGB::Yellow,
CRGB::White,
CRGB::White,
CRGB::Red,
CRGB::Yellow,
CRGB::White,
CRGB::White,
CRGB::Red,
CRGB::Yellow,
CRGB::White,
CRGB::White,
CRGB::Red,
CRGB::Yellow,
CRGB::White,
CRGB::White,
};
#if defined(__AVR_ATtiny85__) && (F_CPU == 16000000L)
clock_prescale_set(clock_div_1); // Enable 16 MHz on Trinket
#endif
// SetupPurpleAndGreenPalette();
//SetupRandomPalette();
uint8_t i, j;
// Serial.print(“soundLevel: “);
// Serial.println(soundLevel);
int numLedsToLight = (map(lvl, 0, 900, 0, N_PIXELS));
//Serial.print(“NumLedsToLight: “);
// Serial.println(numLedsToLight);
// First, clear the existing led values
// Serial.print(“NumLedsToLight: “);
// Serial.println(numLedsToLight);
int servoTwist = (map(lvl, 0, 900, 0, 100));
void SetupRandomPalette()
{
gPal = CRGBPalette16(
CHSV( random8(), 255, 32),
CHSV( random8(), 255, 255),
CHSV( random8(), 128, 255),
CHSV( random8(), 255, 255));
}
// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
CRGB purple = CHSV( HUE_PURPLE, 180, 255);
CRGB green = CHSV( HUE_GREEN, 255, 255);
CRGB black = CRGB::Black;
gPal = CRGBPalette16(
purple, green, black, black,
purple, purple, black, black,
green, green, black, black,
purple, purple, black, black );
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.8px Arial; color: #222222; -webkit-text-stroke: #222222; background-color: #ffffff}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.8px Arial; color: #222222; -webkit-text-stroke: #222222; background-color: #ffffff; min-height: 15.0px}
span.s1 {font-kerning: none}
}