#include <LiquidCrystal.h>
// initialize IR sensor pins
const int ir1Pin = A0;
const int ir2Pin = A1;
const int ir3Pin = A2;
// initialize LED pins
const int led1Pin = 22;
const int led2Pin = 26;
const int led3Pin = 30;
// initialize LCD display pins
const int rs = 12, en = 11, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// initialize sensor thresholds (change these values based on your sensors)
const int irThreshold1 = 500;
const int irThreshold2 = 600;
const int irThreshold3 = 700;
void setup() {
// set LED pins as outputs
pinMode(led1Pin, OUTPUT);
pinMode(led2Pin, OUTPUT);
pinMode(led3Pin, OUTPUT);
// set up LCD display
lcd.begin(16, 2);
// print initial message to LCD display
lcd.print("Medicine Dispenser");
lcd.setCursor(0, 1);
lcd.print("Ready to use");
delay(2000);
}
void loop() {
// read sensor values
int irValue1 = analogRead(ir1Pin);
int irValue2 = analogRead(ir2Pin);
int irValue3 = analogRead(ir3Pin);
// check if medicine is low and blink corresponding LED
if (irValue1 < irThreshold1) {
lcd.clear();
lcd.print("Medicine Low:");
lcd.setCursor(0, 1);
lcd.print("Box 1");
digitalWrite(led1Pin, HIGH);
delay(500);
digitalWrite(led1Pin, LOW);
delay(500);
}
if (irValue2 < irThreshold2) {
lcd.clear();
lcd.print("Medicine Low:");
lcd.setCursor(0, 1);
lcd.print("Box 2");
digitalWrite(led2Pin, HIGH);
delay(500);
digitalWrite(led2Pin, LOW);
delay(500);
}
if (irValue3 < irThreshold3) {
lcd.clear();
lcd.print("Medicine Low:");
lcd.setCursor(0, 1);
lcd.print("Box 3");
digitalWrite(led3Pin, HIGH);
delay(500);
digitalWrite(led3Pin, LOW);
delay(500);
}
// wait a short time before checking sensors again
delay(100);
}
#include <Servo.h>
#include <SoftwareSerial.h>
Servo myservo;
SoftwareSerial SIM900A(2, 3);
SIM900A.begin(9600);
delay(2000);
SIM900A.println("AT");
delay(1000);
SIM900A.println("AT+CMGF=1");
delay(1000);
void makeCall() {
SIM900A.println("ATD+1234567890;"); // Replace "1234567890" with the phone number you want to call
delay(5000); // Adjust this delay as necessary
SIM900A.println("ATH");
delay(1000);
}
void sendSMS(int alarmIndex) {
SIM900A.println("AT+CMGS=\"+1234567890\""); // Replace "+1234567890" with the phone number you want to send the SMS to
delay(1000);
SIM900A.print("It's time to take your medicine: ");
SIM900A.print(medicineType[alarms[alarmIndex].medicineType]);
SIM900A.print(" - ");
SIM900A.print(medicineDose[alarms[alarmIndex].medicineDose]);
SIM900A.print(". Please take it now.");
SIM900A.write(26);
delay(1000);
}