Advertisement here

Advertisement here
Advertisement here

Sunday, July 17, 2022

RTC and Arduino Based Adjustable Motor Timer

Hi after a long time I am here with a timer for you which's very useful for home appliances as you can see in title.

In daily life we analyze that some appliances are helping in human life to overcome the human efforts and struggles like water pump, washing machines refrigerator's etc. but we also concern with utilization of power as well. So we want to manage these things in a good and desire manners.

So here is a Arduino and real time clock RTC based adjustable timer for your appliance. You Just set you desire minutes to ON the appliance in each hour then save that. Than you will be feel easy.

This Circuit is especially design for water pump to suck the water from the ground after each hour.

Function buttons:

set: Press to enter in setting mode for timer ON and OFF minutes, Real time setting, Day setting then saving that values

++ : is use to increase values

-- : is use to decrease values

AOM : is empty right now for one more advancement I want to do (I will share in next version)

Components used:

  •     Arduino Uno
  •     RTC (DS1307)
  •     LCD 16x2
  •     Push button
  •     7805 Regulators
  •     SPDT Relay 12v operated
  •     TIP147
  •     Optocoupler 817
  •     Resistors 10k, 220
  •     Pot-meter 5k for Contrast control with LCD
  •     12v adopter 2A
  •     Li cell for RTC
You can get all the components online from Electronics world by just clicking here

Circuit diagram: Proteus file


Arduino program:

// RTC and Arduino based Motor timer //
//  FHQ Design, 30 July,2022         //
//www.elektronicsgarage1.blogspot.com//
 
// Date and time functions using a DS1307 RTC connected via I2C and Wire lib
#include <Wire.h>
#include <LiquidCrystal.h>
#include "RTClib.h"

RTC_DS1307 rtc;
const int rs = 2, en = 3, d4 = 4, d5 = 5, d6 = 6, d7 = 7;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
//RTC_DS1307 RTC;

//************Button*****************//
int Bset  =8; // Button SET MENU'
int Binc  =9; // Button +
int Bdec  =10; // Button -
int Baom  =11; // Auto or Manual
int motor =12; // motor control pin
int LED   =13;   // led



 //void now_time();
int manu=0,hr=0,mint=0,mintcheck=0,On_time=3,daycheck=0;
int ONt,OFFt;
int yearm, monthm, daym=daym+2, hourm=12, minutem=12, secm=12;
char daysOfTheWeek[7][12] = {"Sun   ", "Mon   ", "Tue    ", "Wed      ", "Thu     ", "Fri   ", "Sat     "};
//#define label;
void setup () 
{
  lcd.begin(16,2);
  lcd.clear();
  Serial.begin(9600);
  while (!Serial) {
    ; // wait for serial port to connect. Needed for native USB port only
  }
  Serial.println("Goodnight moon!");
  
  pinMode(Bset,INPUT); 
  pinMode(Binc,INPUT);
  pinMode(Bdec,INPUT);
  pinMode(Baom,INPUT);
  pinMode(LED,OUTPUT);
  pinMode(LED, OUTPUT); // Set buzzer as an output
  pinMode(motor, OUTPUT);
  digitalWrite(motor, HIGH);  
  Wire.begin();
//  RTC.begin();
  //Serial.begin(9600);
   
  if (! rtc.begin()) 
  {
    lcd.print("Couldn't find RTC");
    while (1);
  }

  if (! rtc.isrunning()) 
  {
    lcd.print("RTC is NOT running!");
  }
  
   rtc.adjust(DateTime(F(__DATE__), F(__TIME__)));//auto update from computer time
  // rtc.adjust(DateTime(yearm, monthm, daym, hourm, minutem, secm));// to set the time manualy 
  //setTime(varHr, varMin, varSec, vardd, varmm, varyy);
}

void loop () 
{
  // Function Modes changing //
  //delay(10);
  //int sw = digitalRead(Bset);delay(100);
  if (digitalRead(Bset) == LOW){
  //for (int x=0;x<=1000;x++){}
  delay(500);manu++;
  //lcd.print("Function #");
  //lcd.print(manu);
   if (manu>6){
    manu=0;}
  }

  // Functions //
  
    if (manu==0){
    now_time();
    setmotor();
   delay(10);
   }
//label:   
    if (manu==1){
      motor_ONtime();}

    if (manu==2){
      motor_OFFtime();}
      
    if(manu==3){
      sethr_T();} 
    
    if(manu==4){
      setmin_T();}

     if(manu==5){
      setday_w();}
      
    if(manu==6){
    Save_Prog();}
}
    void now_time()
    {
    DateTime now = rtc.now();
    
    lcd.setCursor(0, 0); // 12:45:78 * * mon
    
    /* Serial.print(now.hour());
     Serial.print(":");
     Serial.print(now.minute());
     Serial.print(":");
      Serial.print(now.second());
     Serial.println();*/
    
    lcd.print(now.hour());
    hr=now.hour();
    lcd.print(':');
    lcd.print(now.minute());
    mint = now.minute();
    mintcheck=now.minute();
    lcd.print(':');
    lcd.print(now.second());
    lcd.print(" *_* ");
    lcd.print(daysOfTheWeek[now.dayOfTheWeek()]);
    daym=now.dayOfTheWeek();
   // daym=daym-2;
    //lcd.setCursor(0, 1);
   // lcd.print("                ");
    delay(10);
    }
    /*
    lcd.setCursor(0, 1);
    lcd.print(now.day());
    lcd.print('/');
    lcd.print(now.month());
    lcd.print('/');
    lcd.print(now.year());
   */
   
   void setmotor(){ // 0
     lcd.setCursor(0, 1);
   lcd.print("Motor.T =   ->  ");
   lcd.setCursor(10, 1);
   lcd.print(ONt, DEC);
   lcd.setCursor(14, 1);
   lcd.print(OFFt, DEC);    
   
   if ((ONt<= mintcheck)&&(mintcheck<OFFt)){digitalWrite(motor, LOW);
   lcd.setCursor(0, 1);
  lcd.print("Motor ON="); delay(500);
  }
   else digitalWrite(motor, HIGH);
   delay(10);
   }
   
   void motor_ONtime(){ // 1
             
             if (digitalRead(Binc)== LOW)
                {delay(500);ONt++;
                if (ONt>60){lcd.setCursor(10, 1);lcd.print("(^_^)");delay(1000);ONt=0;}}
           if (digitalRead(Bdec)== LOW)
                {delay(500);ONt--;
                if (ONt<0){lcd.setCursor(10, 1);lcd.print("(^_^)");delay(1000);ONt=60;}}// 1
    //On_time = ONt; 
   lcd.setCursor(0, 0);
   lcd.print(" Set motor time ");
   lcd.setCursor(0, 1);
   lcd.print("ON Time =       ");
   lcd.setCursor(10, 1);
   lcd.print(ONt, DEC);  
   //Serial.println(" Set motor time ");
   }
   void motor_OFFtime(){ // 2
             
             if (digitalRead(Binc)== LOW)
                {delay(500);OFFt++;
                if (OFFt>60){lcd.setCursor(11, 1);lcd.print("(^_^)");delay(1000);OFFt=0;}}
           if (digitalRead(Bdec)== LOW)
                {delay(500);OFFt--;
                if (OFFt<0){lcd.setCursor(11, 1);lcd.print("(^_^)");delay(1000);OFFt=60;}}// 1
    //On_time = OFFt; 
   lcd.setCursor(0, 0);
   lcd.print(" Set motor time ");
   lcd.setCursor(0, 1);
   lcd.print("OFF Time =      ");
   lcd.setCursor(11, 1);
   lcd.print(OFFt, DEC);  
   //Serial.println(" Set motor time ");
   }
   
   void sethr_T(){  // 3
      lcd.setCursor(0, 0);
   lcd.print(" Set Hours time ");
   if (digitalRead(Binc)== LOW)
                {delay(500);hr++;
                if (hr>24){lcd.setCursor(10, 1);lcd.print("(^_^)");delay(1000);hr=1;}}
           if (digitalRead(Bdec)== LOW)
                {delay(500);hr--;
                if (hr<0){lcd.setCursor(10, 1);lcd.print("(^_^)");delay(1000);hr=24;}}
   lcd.setCursor(0, 1);
   lcd.print("Hours =         ");
   lcd.setCursor(10, 1);
   lcd.print(hr);
   //now.hour()=hr;
   delay(10); }
  
   void setmin_T(){ // 4
      lcd.setCursor(0, 0);
   lcd.print(" Set Minute time ");
   if (digitalRead(Binc)== LOW)
                {delay(500);mint++;
                if (mint>60){lcd.setCursor(11, 1);lcd.print("(^_^)");delay(1000);mint=1;}}
           if (digitalRead(Bdec)== LOW)
                {delay(500);mint--;
                if (mint<0){lcd.setCursor(11, 1);lcd.print("(^_^)");delay(1000);mint=24;}}
   lcd.setCursor(0, 1);
   lcd.print("Minute =        ");
   lcd.setCursor(11, 1);
   lcd.print(mint);
   delay(10); }

  void setday_w(){ // 5
   //int mint;
   lcd.setCursor(0, 0);
   lcd.print("  Set Week Day  ");
//lcd.setCursor(0, 1);
   // lcd.print(daycheck);
   if (digitalRead(Binc)== LOW)
                {delay(500);daym++;
                if (daym>6){lcd.setCursor(10, 1);lcd.print("(^_^)");delay(1000);daym=0;}}
           if (digitalRead(Bdec)== LOW)
                {delay(500);daym--;
                if (daym<0){lcd.setCursor(10, 1);lcd.print("(^_^)");delay(1000);daym=6;}}
   lcd.setCursor(0, 1);
   lcd.print("Day =           ");
   lcd.setCursor(10, 1);
  lcd.print(daysOfTheWeek[daym]);       // sun mon tue wed thu fri sat
   delay(10); }                         //  0   1   2   3   4   5   6
                                        //  2   3   4   5   6   0   1
   void Save_Prog(){ // 6
   lcd.setCursor(0, 0);
   lcd.print("Wait Data Saving");
   hourm=hr;
   minutem=mint;
   daym=daym+2;
   rtc.adjust(DateTime(yearm, monthm, daym, hourm, minutem, secm));// to set the time manualy
   manu =0; 
   delay(1000);
   
            if (OFFt<=ONt){
                lcd.setCursor(0, 0);
                lcd.print("Motor.T =   ->  ");
                lcd.setCursor(10, 0);
                lcd.print(ONt, DEC);
                lcd.setCursor(14, 0);
                lcd.print(OFFt, DEC);   
                lcd.setCursor(0, 1);
                lcd.print("Error::OFFt>ONt");
                delay(1000);
                manu=1;
                }
                
  // On_time = ONt;
  delay(1000);  }



If you like my project ! Plz share it and comment me 
Thanks
Read More

Sunday, July 18, 2021

One Week Session On PIC Microcontroller Programming and Practicals (Manual)

 


Here is a very short lab manual of PIC microcontroller practical’s for beginners students to develop an interest in the Microcontroller field.

I appreciate those students who attend this session with full interest especially Mr. M. Ahzam Roll 2181104 DAE Electronics 3rd year.

This was a one-week session and I also Thanks to Zonal Manager Mr. Majid Afzal, Principal Mr. Haroon Alim, Lab Engineer Mr. Engr Faizan Ahmed and Special Thanks to the Swedish Institute of Technology Rawalpindi for this session.

 

Plate form required:

Proteus 8.6 (any latest)

MikroC Pro for PIC v7

Hardware:

Digital Trainer

PIC Microcontroller 16F84A and 18F452

Genius Universal IC Burner GEN540

Crystal, capacitors, Resistors, Buttons, LEDs, and Jumper wires

 

Trainer:

Fayyaz Hussain

Sr. Instructor Electronics

DAE, B-Tech, MSc, and MS Electronics

Swedish Institute of Technology Rawalpindi

Contents

Preface: 4

Plate form required: 4

Trainer: 4

How to create New Project in MikroC. 5

Step 1: 5

Step 2: 5

Step 3: 6

Step 4. 6

Step 5: 7

Step 6: 7

Step 7: 8

PINOUTs. 9

PIC16F84A: 9

PIC18F452: 9

LAB 01: LED blinking forever. 10

Circuit: 10

Code: 10

LAB 02: LED blinking for 10 time. 11

Circuit: 11

Code: 11

LAB 03: LED with Push button. 12

Circuit: 12

Code: 12

LAB 04: Seven segment counter. 13

Pin out of 7 segment C.C: 13

Circuit: 13

Code: 14

LAB 05: Seven segment event counter. 15

Circuit: 15

Code: 16

LAB 06: LEDs Toggling. 17

Circuit: 17

Code: 17

LAB 07: Traffic Signal (one way). 18

Circuit: 18

Code: 18

LAB 08: ADC and Bar graph. 19

Circuit: 19

Code:


Read More

About Auther

Fayyaz Hussain is a Lecturer at Swedish Institute of Technology , He is Electronics Scientist , Tech Engineer , Programmer, web developer and Online Mentor and very Much Professional in PIC Micro controller, Arduino, PLC ( Fatek , Mitsubishi ) MikroC Compiler etc. who has been working since 2015 if you want to know more about him then Please Click Here.

Important Artical

Popular Articals

Total Page views in This Month

© 2019-20 Elektronic Garage. Designed by Fayyaz Hussain & Distributed by elektronicsgarage1.blogspot.com