Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO and HC-05 Bluetooth Controlled Medicine Dispenser with Servo Motors

View and Edit Project In Cirkit DesignerImage of Arduino UNO and HC-05 Bluetooth Controlled Medicine Dispenser with Servo Motors

Circuit Documentation

Summary

This circuit is a Bluetooth-controlled medicine dispenser. It uses an Arduino UNO microcontroller to control three micro servos, which dispense different types of medicine based on commands received via a Bluetooth module (HC-05). The servos are labeled for dispensing Paracetamol, Amlodipine, and Dolo. The Bluetooth module communicates with the Arduino to receive commands and control the servos accordingly.

Component List

HC-05 Bluetooth Module

Arduino UNO

Micro Servo 9G (Paracetamol)

Micro Servo 9G (Amlodipine)

Micro Servo 9G (Dolo)

Wiring Details

HC-05 Bluetooth Module

Arduino UNO

Micro Servo 9G (Paracetamol)

Micro Servo 9G (Amlodipine)

Micro Servo 9G (Dolo)

Code Documentation

Arduino UNO Code

#include <Servo.h>

// Pin configuration
#define SERVO1_PIN 9
#define SERVO2_PIN 10
#define SERVO3_PIN 11

// Servo motor objects
Servo servo1; // Paracetamol
Servo servo2; // Amlodipine
Servo servo3; // Dolo

// Bluetooth input string
String bluetoothInput = "";

void setup() {
  // Attach servos to their pins
  servo1.attach(SERVO1_PIN);
  servo2.attach(SERVO2_PIN);
  servo3.attach(SERVO3_PIN);

  // Set initial servo positions to 0 degrees
  servo1.write(0);
  servo2.write(0);
  servo3.write(0);

  // Initialize Bluetooth communication on Arduino TX and RX
  Serial.begin(9600);

  // Display welcome message via Serial Monitor
  Serial.println("Medicine Dispenser Ready");
}

void loop() {
  // Check for Bluetooth input
  if (Serial.available()) {
    char receivedChar = Serial.read();

    // If end of input is detected
    if (receivedChar == '\n') {
      processInput(bluetoothInput);
      bluetoothInput = ""; // Reset input string
    } else {
      bluetoothInput += receivedChar; // Append character to input
    }
  }
}

void processInput(String input) {
  input.trim(); // Remove any leading/trailing whitespace

  if (input.equalsIgnoreCase("paracetamol")) {
    dispenseMedicine("Paracetamol", servo1);
  } else if (input.equalsIgnoreCase("amlodipine")) {
    dispenseMedicine("Amlodipine", servo2);
  } else if (input.equalsIgnoreCase("dolo")) {
    dispenseMedicine("Dolo", servo3);
  } else {
    Serial.println("Invalid Medicine");
  }
}

void dispenseMedicine(String medicineName, Servo &servo) {
  // Display dispensing message via Serial Monitor
  Serial.println("Dispensing: " + medicineName);

  // Rotate the servo to dispense
  servo.write(90); // Rotate to 90 degrees
  delay(1000); // Wait for 1 second
  servo.write(0); // Return to 0 degrees
  delay(500); // Wait for half a second

  // Indicate ready state
  Serial.println("Ready");
}

This code initializes the servos and sets up Bluetooth communication. It listens for commands via Bluetooth and dispenses the corresponding medicine by rotating the appropriate servo motor.