Electronic Pill Box

A smart gadget designed to remind elder people about the pill taking time.

IntermediateFull instructions provided2 days1,467
Electronic Pill Box

Things used in this project

Hardware components

MSP-EXP430G2 MSP430 LaunchPad
Texas Instruments MSP-EXP430G2 MSP430 LaunchPad
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1
LED (generic)
LED (generic)
×4
Buzzer, Piezo
Buzzer, Piezo
×1

Software apps and online services

Energia
Texas Instruments Energia
MIT App Inventor
MIT App Inventor

Story

Read more

Code

energia code

Arduino
pill box
#include<string.h>

//int led1=11,led2=12,led3=13,led4=18,buzz=19;
String a;
String str;

  void ledblink(int,char);
  void buzzer(int, char);


void setup()
{
  pinMode(11,OUTPUT);
  pinMode(12,OUTPUT);
  pinMode(13,OUTPUT);
  pinMode(18,OUTPUT);
  pinMode(19,OUTPUT);
  
  Serial.begin(9600);
  digitalWrite(11,LOW);
  digitalWrite(12,LOW);
  digitalWrite(13,LOW);
  digitalWrite(18,LOW);
  noTone(19);
  // put your setup code here, to run once:

}

void loop() {
  if(Serial.available()>0)
     while(Serial.available())
      {
//         for(int i=0;i<3;i++)
//         { 
          while(!Serial.available());
          a=Serial.readString();
          str=a;
//        } 
        //str =str + a;
      }
      //Serial.println(str);    
       
  if(str[0]=='0' && str[1]=='0' && str[3]=='1') // for compartment1
    { 
      
      ledblink(11,str[2]);
     
     digitalWrite(12,LOW);
     digitalWrite(13,LOW);
     digitalWrite(18,LOW);
       buzzer(19,str[2]);
       
     }
 
 
  if(str[0]=='0' && str[1]=='1' && str[3]=='1') // for compartment2
   {
      ledblink(12,str[2]);
    digitalWrite(11,LOW);
     digitalWrite(13,LOW);
      digitalWrite(18,LOW);
       buzzer(19,str[2]);
   }
   
  if(str[0]=='1' && str[1]=='0' && str[3]=='1')// for compartment3
   {
    ledblink(13,str[2]);
    digitalWrite(11,LOW);
     digitalWrite(12,LOW);
      digitalWrite(18,LOW);
       buzzer(19,str[2]);
   }

  if(str[0]=='1' && str[1]=='1' && str[3]=='1')// for compartment4
   {
      ledblink(18,str[2]);
       digitalWrite(11,LOW);
        digitalWrite(12,LOW);
         digitalWrite(13,LOW);
       buzzer(19,str[2]);
   }
   if(str[3]=='0')
    {
       digitalWrite(11,LOW);
        digitalWrite(12,LOW);
         digitalWrite(13,LOW);
         digitalWrite(18,LOW);
         noTone(19);
    }
 }

 void ledblink(int LED,char n) //for LED blinking
   { if(n=='0')
      {
        digitalWrite(LED,HIGH); 
        delay(800);
        digitalWrite(LED,LOW);
        delay(800);
      }
    if(n=='1')
      {digitalWrite(LED,HIGH);
        delay(100);
        digitalWrite(LED,LOW);
        delay(100);
      }
   }
  
   void buzzer(int buzz,char n) // for buzzer alarm 
   { if( n=='0')
      { 
        tone(buzz,1000);   //giving 1Khz signal to buzzer
        delay(800);
        noTone(buzz);
        delay(800);
      }

     if( n=='1')
       {
        tone(buzz,1000);   //giving 1Khz signal to buzzer
        delay(50);
        noTone(buzz);
        delay(50); 
       }
   }
   

Credits

Dr. Umesh Dutta

Dr. Umesh Dutta

38 projects • 53 followers
Working as Director of Innovation Centre at Manav Rachna, India. I am into development for the last 12 years.
Texas Instruments University Program

Texas Instruments University Program

91 projects • 119 followers
TI helps students discover what's possible to engineer their future.
Energia

Energia

34 projects • 26 followers
Founder of @energiaproject
Vinayak Pahujani

Vinayak Pahujani

1 project • 1 follower
Soniya Bhandari

Soniya Bhandari

1 project • 0 followers
Vikas Pandey

Vikas Pandey

1 project • 0 followers

Comments