-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelper_functions.ino
More file actions
executable file
·31 lines (26 loc) · 1.17 KB
/
helper_functions.ino
File metadata and controls
executable file
·31 lines (26 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Parameter 1 = number of pixels in strip, neopixel stick has 8
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_RGB Pixels are wired for RGB bitstream
// NEO_GRB Pixels are wired for GRB bitstream, correct for neopixel stick
// NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels)
// NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip), correct for neopixel stick
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NEOPIXEL_COUNT, NEOPIXEL_DATA_PIN, NEO_GRB + NEO_KHZ800);
// Define the color codes by name to make it easier to call later on
uint32_t red = strip.Color(128, 0, 0);
uint32_t green = strip.Color(0, 128, 0);
uint32_t yellow = strip.Color(128, 128, 0);
uint32_t blue = strip.Color(0, 0, 128);
uint32_t black = strip.Color(0, 0, 0);
// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
for(uint16_t i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, c);
strip.show();
delay(wait);
}
}
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max)
{
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}