EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / water level controller

water level controller

|

Microcontroller › AVR › water level controller

  • This topic has 8 replies, 4 voices, and was last updated 14 years, 6 months ago by pranav patel.
Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • July 11, 2011 at 4:42 am #1053
    query
    Participant

    I am Maneesh PK, India,I am doing a project to display and control water level in a tank using atmega16 micro controller. I am using a pot and arm mechanism to measure the level of water. I am getting 0V corresponding to zero water level and 2.7V for 100% water level. I am using a 16×2 lcd. I need to use the built-in adc with input at PA0, and need to display the water level as percentage. Continuous variation from 0% to 100% is to be displayed. Will you please help me sir..

    July 23, 2011 at 6:14 am #6502
    dagakshay
    Participant

    hi Maneesh,

    refer her for AVR inbuilt ADC

    http://www.engineersgarage.com/embedded/avr-microcontroller-projects/adc-circuit

     

    to display no on LCD

    http://www.engineersgarage.com/microcontroller/8051projects/display-number-LCD-AT89C51-circuit

    July 23, 2011 at 5:52 pm #6509
    Maneesh PK
    Participant

    ok it is fixed….

     

    now it is displaying the level….

    i wrote cammand to turn the motor on and of at desired levels

    i am using port a for adc

    port b for display data

    port d for keypad

    and c for lcd control and motor control…

     

    C0, C1 and C2 are display control

     

    and C7 as motor control

     

    my program is like

     

    main

    {

    //port initialisatn

     

    while(1)

     

    {

    //read adc and display

     

    //if less than lower level motor on

     

    //if greater then upper level motor off

     

     

    }

     

     

    }

     

    i defined PORTC=ctrl

    PC7=motor

     

    and wrote 

    ctrl=(1<<motr); to turn motor on

     

     

    but when level is low the line for motor is not steady…..

    i mean if i connect an led there it is blinking…

     

    please help……

     

     

    July 25, 2011 at 5:49 am #6515
    dagakshay
    Participant

    while(1)

    {

    read adc();

    if (adc<lower levl)

        {

        while(adc<upper level)

              {

              motor is on;

               read adc();

               }

         motor is off;

        }

    else

    motor is off;

    }

    August 2, 2011 at 9:07 am #6558
    Maneesh PK
    Participant

     

    the motor is turning on at lower level. but it is not getting off. it is getting stuck inside the while loop…

     

    while(1)
            {
                    adc_init();
                    adcout=adc_getvalue(0);
                    _delay_ms(1);
                    LCD_cmd(0xc0);
                    char ready[50];
                    itoa(adcout,ready,10);
                    LCD_write_string(ready);
                    LCD_write_string(“%   “);
                    _delay_ms(1);
     

                   PORTD=0xF0;        //set all the input to one
                   value=PIND;        //get the PORTD value in variable “value”      

                  if(value!=0xf0)        //if no key is pressed value changed
                   

                   {
                    key=’0′;
                   
                    check1();
                    check2();
                    check3();
                    check4();

                    if (key==’M’)
                        {
                        Menu();
                        }
                   
                    else if (key==’0′)
                            {
                           
                            }
               
                    else
                        {
                        ctrl=(1<<buzz);
                        _delay_ms(100);
                        ctrl=(0<<buzz);
                        _delay_ms(1);
                       
                        }

                    }

                if (adcout<00001010)
                    {

                    while (adcout<=00101100)
                        {
                        ctrl=(1<<motr)|(1<<led);
                        _delay_ms(1);
                        adc_init();
                        adcout=adc_getvalue(0);
                        _delay_ms(1);

                       
                        }
                        ctrl=(0<<motr)|(0<<led);
                        }

                else
                    {
                        ctrl=(0<<motr)|(0<<led);
                       
                    }
    }

    }

     

    if motor is once turned on, i should have to reset to turn it off even after lelev cross higher level

     

    pls help

    August 4, 2011 at 10:35 am #6573
    dagakshay
    Participant

    what is the varible type of adcout???

    is that char, uchar, int, uint???

     

    try to use voilatile uint16_t <variable name>;

     

    August 4, 2011 at 10:38 am #6574
    dagakshay
    Participant

    And in the loops you using

    ”  
                if (adcout<00001010)
                    {

                    while (adcout<=00101100)
                        {

     

    “

     

     

    is that integer value???

     

    if you are looking for binary value you must write 0b10101010 as same as 0xAA;

    let me know till where you have reached

    August 15, 2011 at 7:30 am #6608
    Maneesh PK
    Participant

    Thanx…..

    When i added 0b with the binary value it worked….

     

    I defined adcout as int.

    I have variation of 0x00 to 0x32 (0d50).

    So i just multiplied adcout by 2 (0b10)

    Converted into decimal charactor by itoa()

    and desplayed.

    Now it is working…

     

     

     

    I also have a 4×4 keypad.

    And i need to change the limits using it

     

    The keys are like

     

    Menu         1        2           3

    Back          4        5           6

    Exit            7        8           9

    Delete     Left       0       Right

     

     

     

    So while working if i type 50 for lower limit and 95 for higher limit and set it, after that the motor should turn on when level goes below 50%. and off above 95%.

     

     

     

     

    I was doing like this.

    When higher limit option is selected it will call  the function higher_limit()

     

     

     

     

     

    void higher_limit(void)
    {
     
    init_LCD();
    LCD_write_string(“ENTER LIMIT”);
    LCD_cmd(0xC0);
    key=0;
     
    int i;
    i=0;
     
     
     
    while(1)
     
    {
     
    PORTD=0xF0;
    value=PIND;
    key=0;
    _delay_ms(100);
     
    if (value!=0xf0)
     
    {
    check1();
    check2();
    check3();
    check4();
     
    if (key==’M’)
    {
    init_LCD();
    LCD_write_string(“LIMIT IS SET”);
    LCD_cmd(0x0c);
    LCD_write_string(h_l);
    LCD_cmd(0xc0);
    _delay_ms(500);
    main();
     
    }
     
    else if (key==’B’)
    {
    edit_limits();
    }
    else if (key==’E’)
    {
    main();
    }
     
    else if (key==’1′)
    {
    LCD_write_string(“1”);
    _delay_us(1);
    h_l=1;
     
    }
    else if (key==’2′)
    {
    LCD_write_string(“2”);
    _delay_us(1);
    h_l=2;
     
    }
     
    else if (key==’3′)
    {
    LCD_write_string(“3”);
    _delay_us(1);
    h_l=3;
     
    }
    else if (key==’4′)
    {
    LCD_write_string(“4”);
    _delay_us(1);
    h_l=4;
     
    }
    else if (key==’5′)
    {
    LCD_write_string(“5”);
    _delay_us(1);
    h_l=5;
     
    }
    else if (key==’6′)
    {
    LCD_write_string(“6”);
    _delay_us(1);
    h_l=6;
     
    }
    else if (key==’7′)
    {
    LCD_write_string(“7”);
    _delay_us(1);
    h_l=7;
     
    }
    else if (key==’8′)
    {
    LCD_write_string(“8”);
    _delay_us(1);
    h_l=8;
     
    }
    else if (key==’9′)
    {
    LCD_write_string(“9”);
    _delay_us(1);
    h_l=9;
     
    }
     
    else if (key==’Z’)
    {
    LCD_write_string(“0”);
    _delay_us(1);
    h_l=0;
     
    }
     
    else if (key==’D’)
    {
    LCD_cmd(0x10);
    LCD_write_string(” “);
    _delay_us(1);
    LCD_cmd(0x10);
    i=i-1;
    }
     
    i=i+1;
     
     
     
    }
     
    }
     
    }
     
     
     
     
     
     
     
     
    I was planning to convert h_l into some integer value and compare…
     
    But it is not working…
     
     
    Also for delete what i have done is that
    move cursor left;
    print one space;
    move cursor left;
     
    is there any other way for it?…
     
     
    I defined variable h_l as char.

    char h_l [50];

     

     

     

    how can i make it  ?  ……

    August 17, 2011 at 8:04 am #6609
    pranav patel
    Participant

    this is  mt project for

     

    “water level controller  usnig two tank”

     

    now we have done to make prograam in programming in C

     

    but we not make in keil software bcz we dont know that 

     

    Descripation of project.

     

     

     

    ”  here we have used  two tank in 

    water level controller

    now in there we have taked 4 level.

     

    it is 

     

    a = lower tank low level

    b = lower level high level

    c = upper tank low level

    d = upper tank high level

     

    here,

    condition

     

    1=full tank,

     

    0= empty tank

     

    and we also used to 

     

    motor and alarm.

     

    now  my program is here

     

     

     

     

    #include<stdio.h>
    #include<conio.h>
    void main()
    {
    int a,b,c,d,motor,alarm;
    float 1=full, 0=empty;
    clrscr();
    printf(“/n motor on/off, alarm on/off”);
    while
    {
    switch
    case(1);
    {
    a=1,b=1,c=1,d=1;
    motor(off);
    alarm(off);
    break;
    }
    case(2);
    {
    a=1,b=1,c=1,d=0;
    motor(off);
    alarm(off);
    break;
    }
    case(3);
    {
    a=1,b=1,c=0,d=0;
    motor(on);
    alarm(off);
    break;
    }
    case(4);
    {
    a=1,b=0,c=0,d=0;
    motor(on);
    alarm(off);
    break;
    }
    case(5);
    {
    a=0,b=0,c=0,d=0;
    motor(off);
    alarm(on);
    break;
    }
    default;
    }
    }
    getch();

     

     

     

    patel pranav v.

     

    gov. polytechnic 

    rajkot

    diploma in e.c.

     

     

     

     

  • Author
    Posts
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • RC Electronic Speed Control Capacitors February 17, 2026
  • Annex32 / Annex RDS For ESP Micros - A Quick and Dirty Example February 16, 2026
  • Convenient audio FFT module? February 16, 2026
  • CR2/CR123A Batteries In Projects February 16, 2026
  • Harman Kardon radio module BMW noise February 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise