/*
Arduino | hardware-help
IRMoleman — 6/7/24 at 11:04 AM
Any chance you could have a look at
https://www.tinkercad.com/things/1Ib6WMR8970-message-board
*/
#include <LiquidCrystal.h>
const int MAX_STRINGS = 10;
const int NUM_USER_BTNS = 3;
const int NUM_LEDS = 4;
const int LED_PINS[NUM_LEDS] = {6, 5, 4, 3};
const int BTN_PINS[NUM_USER_BTNS] = {A3, A2, A1};
const int RST_PIN = A0;
// Unique messages
const char UNIQUE_MSGS[NUM_USER_BTNS][21] = { // max 20 chars + \0
"Unique Message 1",
"Unique Message 2",
"Unique Message 3"
};
// Array of 50 different messages (--> probably won't fit)
String messages[MAX_STRINGS] = {
"You Are Strong",
"You Are Loved",
"You Are Brilliantly Smart",
"You Are Kind And Caring",
"You Deserve Love",
"You Are Stunning",
"You Are Not Your Bad Days",
"You Have Pushed Through Your Bad Days And Come Out On top Everytime",
// Add more messages here
};
int btnStates[NUM_USER_BTNS];
int pastBtnStates[NUM_USER_BTNS];
int affirmState;
int pastAffirmState;
LiquidCrystal lcd(12, 11, 10, 9, 8, 7);
void checkButtons() {
// do custom buttons
for (int i = 0; i < NUM_USER_BTNS; i++) {
pastBtnStates[i] = btnStates[i];
btnStates[i] = digitalRead(BTN_PINS[i]);
if (btnStates[i] != pastBtnStates[i] && btnStates[i] == LOW) {
Serial.println(UNIQUE_MSGS[i]);
digitalWrite(LED_PINS[i], HIGH);
lcd.clear();
lcd.print(UNIQUE_MSGS[i]);
delay(1000);
lcd.clear();
digitalWrite(LED_PINS[i], LOW);
}
}
// do cycle button
pastAffirmState = affirmState;
affirmState = digitalRead(RST_PIN);
if (pastAffirmState != affirmState && affirmState == LOW) {
for (int i = 0; i < MAX_STRINGS; i++) {
Serial.println(messages[i]);
digitalWrite(LED_PINS[3], HIGH);
lcd.clear();
lcd.print(messages[i]);
delay(1000);
//lcd.clear();
digitalWrite(LED_PINS[3], LOW);
}
}
delay(40);
}
void setup() {
Serial.begin(9600);
lcd.begin(16, 2);
pinMode(BTN_PINS[0], INPUT_PULLUP);
pinMode(BTN_PINS[1], INPUT_PULLUP);
pinMode(BTN_PINS[2], INPUT_PULLUP);
pinMode(RST_PIN, INPUT_PULLUP);
for (int ledPin = 0; ledPin < NUM_LEDS; ledPin++) {
pinMode(LED_PINS[ledPin], OUTPUT);
}
// splash screen
lcd.setCursor(2, 0);
lcd.print("Affirmations");
lcd.setCursor(5, 1);
lcd.print("V1.0.0");
delay(2000);
lcd.clear();
lcd.print("Push any button");
}
void loop() {
checkButtons();
}