Automated Controlled Nebulizer using Arduino

Automated Controlled Nebulizer using Arduino

Required Parts:

Software:
1.Arduino IDE
2.LCD Keypad library          Download link: Click Here..!!
3.LiquidCrystal library          Download link: Click Here..!!

Hardware:
1. Nebulizer         
2. Arduino Uno            
3. MPX5500 Pressure Sensor           more details Click Here
4. Arduino LCD Shield         
5. 5V Buzzer
6. 12V DC Relay                      

Arduino Code:
#include <LiquidCrystal.h>
#include "LCDKeypad.h"
#define HOURS 1
#define MINUTES 2
#define SECONDS 3
#define beeper 12

// The LCD screen
LCDKeypad lcd;
unsigned int hours = 0;
unsigned int minutes = 0;
unsigned int seconds = 0;
unsigned int setting = 0;

unsigned int set = 0;
const int analogInPin = A1;
int sensorValue = 0; 

int Voltage;
volatile byte pulseCount; 
byte relay       = 3; 

void setup() {
  // Set up the LCD's number of columns and rows: 
  lcd.begin(16,2);
lcd.setCursor(0, 1);
    lcd.print("hours  =");
 pulseCount        = 0;

 pinMode(relay, OUTPUT);
digitalWrite(relay, LOW);
 pinMode(beeper, OUTPUT);

}

void loop() {
 if(set == 1) {
  if((hours >= 0) && (minutes >= 0) && (seconds >= 0))
  {
   digitalWrite(relay, HIGH); 
    }
 if((hours == 0) && (minutes == 0) && (seconds == 0))
  {
   digitalWrite(relay, LOW); 
   tone(beeper,300,600);
  delay(100);  
    }  
   stepDown();
  }   
  sensorValue = analogRead(analogInPin);
  float sensorVoltage = sensorValue * (5.0 / 1023.0);
 Voltage=sensorVoltage/0.009;
 sensorVoltage=(Voltage)-(0.2);
sensorVoltage = sensorVoltage * (0.145037738);

 if(sensorVoltage < 3.5)
 {
  sensorVoltage=0;
  }
   lcd.setCursor(0,0);
   lcd.print("Press =");
   lcd.setCursor(7,0);
   lcd.print(sensorVoltage);
  lcd.setCursor(13,0);
   lcd.print("PSI");
// Print the time on the LCD
  printTime();
// Listen for buttons for 1 second
  buttonListen();
    }
//--------------------------------------------------------------// TIMER METHODS------------------------------------------
//-----------------//BUTTONS-----------------------
void buttonListen() {
  // Read the buttons five times in a second
  for (int i = 0; i < 5; i++) {
  // Read the buttons value
    int button = lcd.button();
    switch (button) {
// Right button was pushed
    case KEYPAD_RIGHT:
     digitalWrite( beeper , HIGH); 
     delay(100);   // wait for a second
     digitalWrite( beeper , LOW); 
     delay(100);            // wait for a second
      setting++;
      break;

    // Left button was pushed
    case KEYPAD_LEFT:
      digitalWrite( beeper , HIGH); 
     delay(100);   // wait for a second
     digitalWrite( beeper , LOW); 
     delay(100);           // wait for a second
      setting--;
      break;

    // Up button was pushed
    case KEYPAD_UP:
     {
      digitalWrite( beeper , HIGH); 
     delay(100);   // wait for a second
     digitalWrite( beeper , LOW); 
     delay(100);             // wait for a second
      set = 0;
      switch (setting) {
        case HOURS:
        hours++;
        break;
      case MINUTES:
        minutes++;
        break;
      case SECONDS:
        seconds++;
      }  
      }   
      break;

    // Down button was pushed
    case KEYPAD_DOWN:{
     digitalWrite( beeper , HIGH); 
     delay(100);   // wait for a second
     digitalWrite( beeper , LOW); 
     delay(100);
     set = 0;
      switch (setting) {
      
      case HOURS:
        hours--;
        if (hours == -1) hours = 23;
        break;
      case MINUTES:
        minutes--;
        if (minutes == -1) minutes = 59;
        break;
      case SECONDS:
        seconds--;
        if (seconds == -1) seconds = 59;
      }
      }
      break;
      case KEYPAD_SELECT:
      {
       digitalWrite( beeper , HIGH); 
     delay(100);   // wait for a second
     digitalWrite( beeper , LOW); 
     delay(100);               // wait for a second
        set = 1;
        }
    }
    setting %= 4;
    printSetting();
    hours%=24;
    minutes %= 60;
    seconds %= 60;
    printTime();
// Wait one fifth of a second to complete
    while(millis() % 200 != 0);
  }
}
// Print the current setting
void printSetting() {
  lcd.setCursor(0,1);

  switch (setting) {
    case HOURS:
    lcd.print("Hours  ");
    break;
  case MINUTES:
    lcd.print("Minutes");
    break;
  case SECONDS:
    lcd.print("Seconds");
  }
}

//-----------------//STEP DOWN-----------------------
 //if (seconds > 0) 
  void stepDown() 
  {
 if (seconds > 0) 
{
 seconds -= 1;
 } 
else if (minutes > 0) 
 {
  seconds = 59;
 minutes -= 1;
  }
  else if (hours > 0) 
 {
  minutes = 59;
 hours -= 1;
 }
  }
// Print the time on the LCD
void printTime() {
  // Set the cursor at the begining of the second row
  lcd.setCursor(8,1);
  char time[17];
  sprintf(time, "%02i:%02i:%02i", hours, minutes, seconds);
  lcd.print(time);
}
void pulseCounter()
{
  pulseCount++;
}

No comments:

Post a Comment