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 / Replies / HI   code software

HI   code software

|

Microcontroller › AVR › Error using Lm35 Interface with Atmega 16 › HI   code software

September 17, 2013 at 8:32 am #10462
mohammad amin
Participant

HI

 

code software LM35

 

#include <mega16.h>
#include <stdio.h>
#include <delay.h>
#asm
   .equ __lcd_port=0x18 ;PORTB
#endasm
#include <lcd.h> 
#define  Up        PIND.0
#define  Down      PIND.1
#define  Enter     PIND.2 
#define  high_LED  PORTA.1
unsigned char compare=0,set=0xff;
float   temp; 
//__________________________________________
void display(){  
char   lcd_buf[32];
sprintf(lcd_buf,”Temp=%3.1fxdfCnHigh Temp=%i”,temp,compare);
lcd_clear();
lcd_gotoxy(0,0);
lcd_puts(lcd_buf);
lcd_gotoxy(13,1);
if(high_LED==1) lcd_putsf(“on “);
if(high_LED==0) lcd_putsf(“off”);
} 
//_________________________________________                        
interrupt [ADC_INT] void adc_isr(void){
unsigned int adc_data;
adc_data=ADCW;
temp=adc_data*2.56/1024; 
temp=temp*100;
if(temp>=set) high_LED=1;
else high_LED=0;
}
//_________________________________________up
void inc_set_temp(){
if(compare<99) compare++;
}
//__________________________________________Down
void dec_set_temp(){
if(compare!=0) compare–;
}             
//__________________________________________
void main(){
PORTD=0XFF;
DDRD=0X00;
PORTA.1=0;
DDRA.1=1; 
ACSR=0XC0;
SFIOR=0X00;
ADMUX=0XC0;
ADCSRA=0X8F;
lcd_init(16);
#asm(“sei”)
ADCSRA=0XCF;
while(1){
   display();
   delay_ms(250);
   ADCSRA=0XCF;
   if(Up==0)    inc_set_temp();
   if(Down==0)  dec_set_temp();
   if(Enter==0) set=compare;
 };
}

RSS Recent Posts

  • Getting into an LED bulb April 21, 2026
  • understanding of resonance in time domain April 21, 2026
  • Beginner Questions About CNC Machines – G-code, Control Systems & Accuracy April 21, 2026
  • A Must-Watch Video Showing Dangerous Construction of Cheap Lithium-Ion Cells April 21, 2026
  • S1MJ ? April 20, 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