Skip to content

Instantly share code, notes, and snippets.

View mgruben's full-sized avatar

Michael Gruben-Trejo mgruben

View GitHub Profile
@mgruben
mgruben / 24_hour_reminder.ino
Created October 6, 2020 00:19
Feed-the-Fish Timer using RTC
#include <DS3232RTC.h>
#include <LowPower.h>
// pin definitions
const int SQW_PIN = 2;
const int BUTTON_PIN = 3;
const int LED_PIN = 8;
// Arduino DS3232RTC Library
// https://github.com/JChristensen/DS3232RTC
//
// Example sketch illustrating Time library with Real Time Clock.
// This example is identical to the example provided with the Time Library,
// only the #include statement has been changed to include the DS3232RTC library.
#include <DS3232RTC.h> // https://github.com/JChristensen/DS3232RTC
#include <LowPower.h>
@mgruben
mgruben / 24_hour_reminder.ino
Created September 21, 2020 00:23
Low-Power Feed-the-Fish Timer (Earlier bounce)
#include <LowPower.h>
// Define our physical setup
const int HAVE_FED_PIN = 2;
const int EARLIER_PIN = 3;
const int LED_PIN = 8;
// Declare some state-tracking variables
int haveFedButtonPressed = 0;
int alertSoonerButtonPressed = 0;
boolean alertSoonerButtonActive = false;
@mgruben
mgruben / 24_hour_reminder.ino
Created September 19, 2020 00:13
24-hour fish feeder timer using Low Power states
#include <LowPower.h>
// Define our physical setup
const int HAVE_FED_PIN = 2;
const int EARLIER_PIN = 3;
const int LED_PIN = 8;
// Declare some state-tracking variables
int haveFedButtonPressed = 0;
int alertSoonerButtonPressed = 0;
boolean alertSoonerButtonActive = false;
unsigned long previous = 0;
// Set this to the desired delay in ms
const unsigned long DELAY;
void loop() { unsigned long now = millis();
if (now - previous > DELAY) {
// Fire our event
previous = now;
}
// Define our physical setup
const int EARLIER_PIN = 13;
const int LED_PIN = 8;
const int HAVE_FED_PIN = 2;
// Define some configuration
// The "units" of our program
#define SECONDS 1000
#define HOURS 3600000
// Seconds for testing