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 / Help on Controlling Air Condition using LM35 interfacing to PIC microcontroller

Help on Controlling Air Condition using LM35 interfacing to PIC microcontroller

|

Microcontroller › PIC › Help on Controlling Air Condition using LM35 interfacing to PIC microcontroller

  • This topic has 3 replies, 2 voices, and was last updated 12 years, 2 months ago by AJISH ALFRED.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 19, 2013 at 8:31 pm #2693
    Akanbi Ibrahim
    Participant

    Hi everybody,i am working on a project which i have to switch ON and OFF Air Condition whenever the temperature of the room is above or below certain temperature respectively.I have done my breadboard design and the temperature is displaying properly but the automatic switch ON and OFF is not working as expected instead it will not allow the temperature to go below or beyond my minimum and maxmum temperature respectively.below is my code in MikroC

     

    sbit LCD_RS at RC4_bit;
    sbit LCD_EN at RC5_bit;
    sbit LCD_D4 at RC0_bit;
    sbit LCD_D5 at RC1_bit;
    sbit LCD_D6 at RC2_bit;
    sbit LCD_D7 at RC3_bit;
    sbit LCD_RS_Direction at TRISC4_bit;
    sbit LCD_EN_Direction at TRISC5_bit;
    sbit LCD_D4_Direction at TRISC0_bit;
    sbit LCD_D5_Direction at TRISC1_bit;
    sbit LCD_D6_Direction at TRISC2_bit;
    sbit LCD_D7_Direction at TRISC3_bit;
    // End LCD module connections
    // Define Messages
    char message0[] = “AC Monitoring”;
    char message1[] = “Room Temperature”;
    // String array to store temperature value to display
    char *tempC = “000.0”;
    char *tempF = “000.0”;
    // Variables to store temperature values
    unsigned int tempinF, tempinC,orgtemp;
    unsigned long temp_value,maxtemp;
    void Display_Temperature() {
     // convert Temp to characters
     if (tempinC/10000)
     // 48 is the decimal character code value for displaying 0 on LCD
     tempC[0] = tempinC/10000 + 48;
     else tempC[0] = ‘ ‘;
     tempC[1] = (tempinC/1000)%10 + 48; // Extract tens digit
     tempC[2] = (tempinC/100)%10 + 48; // Extract ones digit
     // convert temp_fraction to characters
     tempC[4] = (tempinC/10)%10 + 48; // Extract tens digit
     // print temperature on LCD
     Lcd_Out(2, 1, tempC);
     if (tempinF/10000)
     tempF[0] = tempinF/10000 + 48;
     else tempF[0] = ‘ ‘;
     tempF[1] = (tempinF/1000)%10 + 48; // Extract tens digit
     tempF[2] = (tempinF/100)%10 + 48;
     tempF[4] = (tempinF/10)%10 + 48;
     // print temperature on LCD
     Lcd_Out(2, 10, tempF);
    }
     
    void main()
    {
     
     TRISE=1;
     TRISB=0;
     PORTE=1;
     TRISD=0;
     PORTD=0;
    // ANSEL = 0b00000100; // RA2/AN2 is analog input
     ADCON0 = 0b01001000; // Connect AN2 to S/H, select Vref=1.19V
    // CMCON0 = 0x07 ; // Disbale comparators
     TRISC = 0b00000000; // PORTC All Outputs
     TRISA = 0b00001110; // PORTA All Outputs, Except RA3 and RA2
     Lcd_Init(); // Initialize LCD
     Lcd_Cmd(_LCD_CLEAR); // CLEAR display
     Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
     Lcd_Out(1,1,message0);
     Delay_ms(1000);
     Lcd_Out(1,1,message1); // Write message1 in 1st row
     // Print degree character
     Lcd_Chr(2,6,223);
     Lcd_Chr(2,15,223);
     // Different LCD displays have different char code for degree symbol
     // if you see greek alpha letter try typing 178 instead of 223
     Lcd_Chr(2,7,’C’);
     Lcd_Chr(2,16,’F’);
     while(1) 
     {
     temp_value = ADC_Read(2);
     temp_value = temp_value*4882;
     tempinC = temp_value/1000;
     tempinC = tempinC*10;
     tempinF = 9*tempinC/5 + 3200;
    }
    }
    //~ End of main Function
    October 21, 2013 at 5:02 am #10538
    AJISH ALFRED
    Participant

    Hi Akanbi,

    Air conditioners already have automatic temperature control. It will try to keep the temperature of a room constant, and I guess that is why your project is not working. Please find a way to confirm it first.

     

    November 6, 2013 at 12:47 pm #10577
    Akanbi Ibrahim
    Participant

    Thanks Mr Aljish,but i tried to test this with a LED to see if the temperature is beyond the normal limit i set the LED will ON instead its prevents the temperature that is displaying on the LCD to reach the limit i set.

    November 7, 2013 at 5:04 am #10578
    AJISH ALFRED
    Participant

    Hi Akanbi,

    Check whether your circuit is proper. Make sure that you’ve connected the ADC reference pin of the microcontroller to 5V

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

RSS Recent Posts

  • flexible copper cable January 13, 2026
  • Sears 40/20 200amp starter/battery charger switch pinout January 13, 2026
  • renewed interest in old project I call it WICKED 8 January 13, 2026
  • Drawing software January 13, 2026
  • updating circuit with power on off switching January 13, 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