I always wanted to help my girlfriend remember to take her birth control because it's such an easy thing to forget to do every day. Alarms work pretty well, but if you're in the middle of something or you don't have it with you, you'll sometimes turn off the alarm or snooze it a couple times and then turn it off and end up forgetting before you go to bed, sometimes you don't even notice until the next day when you're supposed to take the next pill and see you didn't take the day before's.
read moreI had the idea of making an Arduino flash a bunch of lights starting at birth control time, and they would continue flashing until you pressed a button. That way if you turned off the lights at the end of the night to go to bed, you'd see the flashing lights and be reminded to take birth control. It worked incredibly well, but I'd definitely recommend buying a real-time clock chip.
/*
This is a program that displays lights (season dependent) for Tara's birth control. 10:15pm.
Pressing the reset button (could upgrade this to the remote, or a nicer button) will stop the lights.
*/
// DS3231 - Version: Latest
// this is the custom written library for using the clock chip
#include
// Init the DS3231 using the hardware interface
// this essentially inits an rtc object, and we specify analog inputs
// 4 and 5 to be used
DS3231 rtc(A4, A5);
int buttonInputPIN = 7;
boolean hasToTakeBC = false;
unsigned long initialDelayBetweenLEDBlinks = 2800;
unsigned long delayBetweenLEDBlinks;
unsigned long delayBetweenSetupBlinks = 200;
// 10:15pm PST would be hour = 22 and min = 15
// 10:15pm EST would be hour = 19 and min = 15
int hour = 22;
int minute = 15;
// this just has the current time, as a datetime essentially, which is
// used for when we pass over the 10:15pm mark
Time currentTime;
boolean debugging = false;
void setup() {
for(int pinCode=2; pinCode<7; pinCode++){
pinMode(pinCode,OUTPUT);
}
Serial.begin(9600);
delayBetweenLEDBlinks = initialDelayBetweenLEDBlinks;
// Initialize the rtc object
rtc.begin();
// display some colors to show that things have been reset/setup
for(int i=0; i<5; i++){
for(int pinCode=2; pinCode<7; pinCode++){
digitalWrite(pinCode, HIGH);
}
delay(delayBetweenSetupBlinks);
for(int pinCode=2; pinCode<7; pinCode++){
digitalWrite(pinCode, LOW);
}
delay(delayBetweenSetupBlinks);
}
}
void loop() {
if(debugging){
// full date and time
Serial.print(rtc.getDOWStr());
Serial.print(" ");
Serial.print(rtc.getDateStr());
Serial.print(" -- ");
Serial.println(rtc.getTimeStr());
// unix time
Serial.println(rtc.getUnixTime(rtc.getTime()));
}
// figure out what the current time is
// this gives us something we can call .hour, .minute, etc. on
currentTime = rtc.getTime();
if(!hasToTakeBC && currentTime.hour == hour && currentTime.min == minute){
Serial.println("Just passed 10:15pm");
hasToTakeBC = true;
}
if(hasToTakeBC){
for(int pinCode=2; pinCode<7; pinCode++){
digitalWrite(pinCode, HIGH);
delay(delayBetweenLEDBlinks);
digitalWrite(pinCode, LOW);
boolean buttonIsPressed = digitalRead(buttonInputPIN);
// if the button is pressed
if(buttonIsPressed){
hasToTakeBC = false;
delayBetweenLEDBlinks = initialDelayBetweenLEDBlinks;
if(debugging){Serial.println("BC Taken.");}
break;
}
}
//make it so that the blinks get more frequent as you wait longer
//time it takes in minutes is: ((((y/x)*(y/2))*5)/1000)/60
//where y is the initial delay and x is the subtracted amount
delayBetweenLEDBlinks -= 6;
if(delayBetweenLEDBlinks <= 30){
delayBetweenLEDBlinks = 30;
}
}
delay (1000);
}