This is an alarm clock that goes off a certain time each day and doesn’t stop until the pills on the top are removed from the red stripe.

Process Images and Review:

I decided to go from an automated refill process to refilling by hand.

I decided to make an individual moveable object rather than integrate it into my physical daily routine.

                                  

Response to Class Comments:

“I wonder if the housing could be smaller; feels like an unnecessarily large footprint for a few components”

A: I purposefully made the housing larger so that the object would call attention to itself, acting as another way to remind me that it was there and I need to take my medication.

“Maybe you could have like a weekly pill dispenser. Like pills are placed in different boxes and dispensed at alarm at each specific day, because an RTC module can also keep the date as well”

A: This was the original goal for this project and I think it’s a great idea. Unfortunately out of my skill set right now but it would be a much more productive invention than my finished product.

Self Critique:

I think that my biggest self-critique is that I could have gone further with the casing and the refill mechanism. I would have liked the casing to be more intentional in its shape and function and made of a more permanent material like wood or acrylic. My original plan was for a linear actuator to move the pills into the break beam sensor day by day as a sort of automated refill mechanism but my technical and coding skills just weren’t strong enough to make that happen for the final product.

What I Learned:

During this process, I learned that the break beam sensor is a surprisingly reliable component and I had the least amount of trouble with it as an input compared to my other inputs and outputs. I also learned that the debugging and trial and error process takes much longer than I planned for and is something that a lot of time needs to be allotted. 

Next Steps:

Going forward I would like to work to make my alarm clock more reliable than it is currently by working out the remaining code and technical bugs. I would also like to see if I can automate the day-by-day “refill” process by using my original concept with the linear actuator.

//Pill Alarm Clock
//Lily Hummel
//This code displays the time, day, and year on a LCD and sets off an alarm at a predetermined time of day.
//When the alarm goes off, it doesn't stop until the breakbeam sensor is unblocked.
//Credit to /https://www.circuitbasics.com/how-to-use-a-real-time-clock-module-with-the-arduino/ and Zach for writing portions of this code.
// YOLO LICENSE
                             //Version 1, July 10 2015

//THIS SOFTWARE LICENSE IS PROVIDED "ALL CAPS" SO THAT YOU KNOW IT IS SUPER
//SERIOUS AND YOU DON'T MESS AROUND WITH COPYRIGHT LAW BECAUSE YOU WILL GET IN
//TROUBLE HERE ARE SOME OTHER BUZZWORDS COMMONLY IN THESE THINGS WARRANTIES
//LIABILITY CONTRACT TORT LIABLE CLAIMS RESTRICTION MERCHANTABILITY SUBJECT TO
//THE FOLLOWING CONDITIONS:
//1. #yolo
//2. #swag
//3. #blazeit


#include <Wire.h>                   // for I2C communication
#include <LiquidCrystal_I2C.h>      // for LCD
#include <RTClib.h>                 // for RTC

LiquidCrystal_I2C lcd(0x27, 16, 2); // create LCD with I2C address 0x27, 16 characters per line, 2 lines
RTC_DS3231 rtc;                     // create rtc for the DS3231 RTC module, address is fixed at 0x68

/*
   function to update RTC time using user input
*/
#define BUZZPIN 9
#define SENSORPIN 4

bool Alarmtrigtoday = false;

bool Wasunblockedtoday = false;
  
// variables will change:
int sensorState = 0, lastState=0;         // variable for reading the pushbutton status

  
void updateLCD()
{

   // get time and date from RTC and save in variables
  DateTime rtcTime = rtc.now();

  

  int ss = rtcTime.second();
  int mm = rtcTime.minute();
  int hh = rtcTime.twelveHour();
  int DD = rtcTime.dayOfTheWeek();
  int dd = rtcTime.day();
  int MM = rtcTime.month();
  int yyyy = rtcTime.year();

  // move LCD cursor to upper-left position
  lcd.setCursor(0, 0);

  // print date in dd-MMM-yyyy format and day of week
  if (dd < 10) lcd.print("0");  // add preceeding '0' if number is less than 10
  lcd.print(MM);
  lcd.print("/");
  lcd.print(dd);
  lcd.print("/");
  lcd.print(yyyy);

  // move LCD cursor to lower-left position
  lcd.setCursor(0, 1);

  // print time in 12H format
  if (hh < 10) lcd.print("0");
  lcd.print(hh);
  lcd.print(':');

  if (mm < 10) lcd.print("0");
  lcd.print(mm);
 

  if (rtcTime.isPM()) lcd.print(" PM"); // print AM/PM indication
  else lcd.print(" AM");
}
void setup()
{      
  pinMode(BUZZPIN, OUTPUT);
  // initialize the sensor pin as an input:
  pinMode(SENSORPIN, INPUT);     
  digitalWrite(SENSORPIN, HIGH); // turn on the pullup
  
  Serial.begin(9600); // initialize serial

  lcd.init();       // initialize lcd
  lcd.backlight();  // switch-on lcd backlight

  rtc.begin();       // initialize rtc
  rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));
}
void loop()
{
  DateTime rtcTime = rtc.now();


  if (rtcTime.second() == 0 && rtcTime.minute() == 14 && rtcTime.hour() == 12){
    tone(BUZZPIN, 200);
    Alarmtrigtoday = true;
    while (sensorState == LOW) { 
      sensorState = digitalRead(SENSORPIN);
    }
    noTone(BUZZPIN);
  }

  
 
  updateLCD();  // update LCD text

}