// https://forum.arduino.cc/t/stranger-things-wall/1424571/5
// Addressable RGBLEDs APA106
#include <FastLED.h> // https://github.com/FastLED/FastLED
#define DATA_PIN 4
#define MATRIX_WIDTH 9
#define MATRIX_HEIGHT 3
#define NUM_LEDS MATRIX_WIDTH * MATRIX_HEIGHT
#define BRIGHTNESS 255
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB pix[NUM_LEDS];
#define BUZZER_PIN A3
#include <RTClib.h> // https://github.com/adafruit/RTClib
RTC_DS1307 rtc;
unsigned long timer, timeout = 500, duration = 500;
int minbright = 64, maxbright = 128, i, j = minbright, k;
// set an alarm
int alarmhour = 9, alarmminute = 0, freq = 185;
const char strangewords[] = { // single-dimension array, no comma delimiters or braces.
// https://youtu.be/6HJNil_cGBU
"Okay...\nOkay... baby...\nTalk to me...\nTalk to me... Where are you?\n'R'*\n"
"Good, good, good...\n'R'*\nThat's good... c'mon, c'mon...\n"
"'I'*\n'G'*\n'H'*\n'T'*\n'H'*\n'E'*\n'R'*\n'E'*\n"
"'Right here,'\n'Right here,'\nI-I-I- don't know what that means.\nI-I-y-y-you just "
"need to tell me what to do.\nWhat should I do?\nHow do I get to you?\nH-H-How do "
"I find you?\nWhat should I do?\n'R'***\n'U'***\n'N'****\n"
// all flash colors at 0.5Hz x 30
};
void setup() {
Serial.begin(300); // teletype effect in the Serial Monitor
// gettextnumbers();
rtc.begin();
randomSeed(analogRead(A0));
pinMode(LED_BUILTIN, OUTPUT);
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(pix, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
FastLED.show();
flickerleds(3);
while (1) {};
Serial.println("(Word Wall as seen on: https://youtu.be/6HJNil_cGBU )\n");
saystuff(0, 8, 2); saystuff(8, 24, 2); saystuff(24, 38, 2); saystuff(38, 52, .5);
saystuff(52, 67, 1); saystuff(67, 72, .5); saystuff(72, 92, 1); saystuff(92, 97, .5);
saystuff(97, 128, 1); saystuff(128, 133, .5); saystuff(133, 138, .5); saystuff(138, 143, .5);
saystuff(143, 148, .5); saystuff(148, 153, .5); saystuff(153, 158, .5); saystuff(158, 163, .5);
saystuff(163, 168, .5); saystuff(168, 182, 1); saystuff(182, 196, 1); saystuff(196, 231, 1);
saystuff(231, 276, 1); saystuff(276, 294, 1); saystuff(294, 315, 1); saystuff(315, 338, 1);
saystuff(338, 356, 1); saystuff(356, 362, 1); saystuff(362, 368, 1); saystuff(368, 373, 1);
}
void loop() {
DateTime now = rtc.now(); // get system time and date
heartbeat(); // toggle LED_BUILTIN
if (now.hour() == alarmhour && now.minute() == alarmminute) // alarm time
throb(); // alarm
}
void saystuff(int first, int last, float delaytime) {
for (int i = first; i < last; i++) {
if (strangewords[i] == '*') {
soundstuff();
}
else
Serial.print(strangewords[i]);
}
delay(delaytime * 1000);
}
void flickerleds(int times) {
// void flickerleds(int times, bool buz) { // concurrent buzzer with flicker
for (int i = 0; i < times; i++) {
// if (buz) { // concurrent buzzer with flicker
// if (millis() - timer > timeout) {
// time = millis();
// digitalWrite(BUZZER_PIN, !digitalRead(BUZZER_PIN));
// }
// }
colorstuff();
FastLED.show();
delay(50);
clearcolor();
FastLED.show();
delay(50);
}
colorstuff();
delay(3000);
clearcolor();
}
void colorstuff() {
/*
AO, BB, CR, DG, EB, FO, GR, HB, IG, JR, KB, LG, MO,
NR, OR, PG, QR, RG, SG, TO, UB, VR, WB, XO, YR, ZR
*/
char ledcolor[] = {"obrgborbwgrbgorrgrbgobrborr"};
for (int i = 0; i < NUM_LEDS; i++) {
switch (ledcolor[i]) {
case 'r': pix[i] = CRGB(255, 0, 0); break;
case 'g': pix[i] = CRGB(0, 255, 0); break;
case 'b': pix[i] = CRGB(0, 0, 255); break;
case 'o': pix[i] = CRGB(255, 128, 0); break;
case 'w': pix[i] = CRGB(255, 255, 255); break;
default: break;
}
}
FastLED.show();
}
void clearcolor() {
for (int i = 0; i < NUM_LEDS; i++)
pix[i] = CRGB(0, 0, 0);
FastLED.show();
}
void soundstuff() {
tone(BUZZER_PIN, freq, 500);
delay(500);
noTone(BUZZER_PIN);
}
void heartbeat() {
if (millis() - timer > timeout) {
timer = millis();
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
}
}
void throb() {
if (k)
pix[i] = CRGB(maxbright + minbright - j, (maxbright + minbright - j) / 2, 0); // decrease color
else
pix[i] = CRGB(j, j / 2, 0); // increase color
FastLED.show();
i++; // pixels
if (i == NUM_LEDS) {
i = 0;
j++; // color
if (j == maxbright) {
j = minbright;
k++; // direction
if (k == 2) {
k = 0;
}
}
}
}
void lightall() { // light all WS2812s
for (int i = 0; i < NUM_LEDS; i++) {
pix[i] = CRGB(16, 32, 64);
FastLED.show();
}
}
void gettextnumbers() {
for (int i = 0; i < sizeof(strangewords); i++) {
if (i < 10) Serial.print(" ");
Serial.print(i);
Serial.print(" ");
Serial.print(strangewords[i]);
Serial.println();
}
while (1) {};
}A
I
R
B
J
S
C
K
T
D
L
U
E
M
V
F
N
W
G
O
X
H
P
Y
Q
Z