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
You are here: Home / Topics / please check my program and correct the mistake …its urgent

please check my program and correct the mistake …its urgent

|

Microcontroller › 8051 › please check my program and correct the mistake …its urgent

  • This topic has 0 replies, 1 voice, and was last updated 9 years, 3 months ago by akhil.
Viewing 1 post (of 1 total)
  • Author
    Posts
  • May 11, 2013 at 9:56 pm #2397
    akhil
    Participant

     heya 

    i m working on a project to control the plant temperature … in this programing first i have measured the temperature stored in “adc_value” variable  and then i showed the measured tep.on the lcd .. nw let the desired plant temp. is 25 .. if the measured temp is 30 then switch on the dc motor .. if it is less than 20 then start the buzzer … i have made lots of mistek please help me out 

     

    in c coding can we use cotrol ststements like

    if (x>=20)

    { do something }

     

    BTW   here is my programing 

     

     

     

    #include<reg51.h> #include<reg51.h>
     
     
     
     
    sbit fan= P1^4;
     
    sbit rs= P2^1;       //lcd rs
    sbit rw= P2^2 ;      //lcd rw
    sbit en=  P2^3 ;      //lcd en
     
    sbit rd= P2^4;                  //Read signal
    sbit wr= P2^5 ;                 //Write signal
    sbit intr= P2^6;                //INTR signal 
     
    sbit buzz=P2^7;                //buzzer 
     
    #define data P3              // adc data pins 
    #define databus P1           //lcd data pins           
     
    void conv();                     //Start of conversion function
    void read();                     //Read ADC function
      
     
     
    void delay(unsigned int count) // stepper motor delay
    {
    int i;
    for(i=0;i<count;i++);
             
    }
     
     
    void ms_delay(int n) // do nothing n * 1ms 
    {      
        int i;
        for  (  ; n>0 ; n–)
            for (i=0; i< 100 ; i++);
    }
     
     
     
    void lcd_puts(unsigned char var)    //write data on lcd
    {
         databus=var;
         rs=1;
         rw=1;
          en=1;
          ms_delay(5);
          en=0;
          ms_delay(10);
    }
     
     
     
     
    void lcd_cmd1(unsigned char var)       //lcd command 
    {
       databus=var;
        rs=0;
        rw=0;
       en=1;
       ms_delay(5);
       en=0;
       ms_delay(10);
    }
     
     
     
    void lcd_initialize()          //lcd initilization 
    {
     
         lcd_cmd1(0x38);            // 2 line and 5*7 matrix
         ms_delay(1);
      
         lcd_cmd1(0x0f);             // cursor on and off
          ms_delay(1); 
     
         lcd_cmd1(0x01);            //clear display screen
         ms_delay(1);   
     
         lcd_cmd1(0x06);            //shift display right
         ms_delay(1);
    }
       
     
     
    void lcd_data(unsigned char *disp)        // function to send string to LCD_puts
     
    {
        int x;
        for(x=0;disp[x]!=0;x++)
         {
        lcd_puts(disp[x]);
          }
    }      
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    void main()                                  //main programme 
    {
    unsigned int adc_value,temp_value;
       P1=0;
        
          lcd_initialize();
     
                lcd_cmd1(0x80);
        lcd_data(”  TEMPERATURE   “);
       
                  lcd_cmd1(0xc0);
        lcd_data(” cONTROLLER “);
    ms_delay(5);
     
                     lcd_cmd1(0x01);
    lcd_cmd1(0x80);
    lcd_data(“submitted by:-“);
            ms_delay(5);
     
                    lcd_cmd1(0x01);
    lcd_cmd1(0x80);
    lcd_data(“aanchal,Aarzoo”);
     
                    lcd_cmd1(0xc0);
    lcd_data(“akansha,Akhil”);
          ms_delay(5);
    lcd_cmd1(0x01);
          
           {
            while(1)                              //Forever loop
                
                 {                                         
                  conv();                  //Start conversion
                    read();                  //Read ADC
                  lcd_puts(adc_value);
                   temp_value=adc_value;
                    }
     
        
                     if(temp_value >= 28)                //  motor on
                {
                    fan=1;
                  ms_delay(70);
                   fan=0;
                  ms_delay(30);
               }
           
     
                         
     
            elseif(temp_value <= 20)         // buzzer on     
          {
           buzz=1;
           ms_delay(2);
           buzz=0;
          }
     
    }
     
     
     
       }
     
     
     
     
     
     
     
     
     
     
    void conv()
       
        {
             wr = 0;                      //Make WR low
            wr = 1;                      //Make WR high
            while(intr);                 //Wait for INTR to go low
         }
     
    void read()
    {
           unsigned int  adc_value;
                     rd= 0;                      //Make RD low
                 adc_value = data;              //Read ADC port
                  rd = 1;                      //Make RD high
     }       
     
     
     
     
     
     
    void lcd_cmd1(unsigned char var)    //lcd command 
    {
       databus=var;
        rs=0;
        rw=0;
       en=1;
       ms_delay(5);
       en=0;
       ms_delay(10);
    }
     
    void lcd_initialize()
    {
       lcd_cmd1(0x38); // 2 line and 5*7 matrix
    ms_delay(1);  
     
     
     lcd_cmd1(0x0f);  // cursor on and off
    ms_delay(1);  
     lcd_cmd1(0x01);  //clear display screen
    ms_delay(1);   
     lcd_cmd1(0x06);  //shift display right
    ms_delay(1);
    }
     
     
        lcd_data(unsigned char *disp)    // function to send string to LCD_puts
    {
    int x;
    for(x=0;disp[x]!=0;x++)
    {
    lcd_puts(disp[x]);
     
    }
    }
     
    void main()
     
    {
    unsigned int adc_value;
     
     
     
    lcd_initialize();
    lcd_cmd1(0x80);
     
    lcd_data(”  TEMPERATURE   “);
     
    lcd_cmd1(0xc1);
     
                     lcd_data(” cONTROLLER “);
    ms_delay(50);
    lcd_cmd1(0x01);
    lcd_cmd1(0x80);
    lcd_data(“submitted by:-“);
    ms_delay(50);
    lcd_cmd1(0x01);
    lcd_cmd1(0x80);
    lcd_data(“aanchal,Aarzoo”);
    lcd_cmd1(0xc0);
    lcd_data(“akansha,Akhil”);
    ms_delay(50);
    lcd_cmd1(0x01);
    {
            while(1)   
    {                                         //Forever loop
                    conv();                  //Start conversion
                    read();                  //Read ADC
                    
          lcd_puts(adc_value);
     
    }
     
    }
    }
     
    void conv()
    {
          
            wr = 0;                      //Make WR low
            wr = 1;                      //Make WR high
            
            while(intr);                 //Wait for INTR to go low
    }
     
    void read()
    {
           unsigned int  adc_value;
           
              rd= 0;                      //Make RD low
            adc_value = data;              //Read ADC port
            rd = 1;                      //Make RD high
     } 
     
     
     
     
     
     
     
     
     
     
  • Author
    Posts
Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Washing Machine motor August 14, 2022
  • arduino help needed August 14, 2022
  • Looking for amplifier ic August 14, 2022
  • Light Automation via mqtt August 14, 2022
  • Right channel distortion on vintage fisher rs-2010 August 14, 2022

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2022 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