من کد ترجیحا به زبان C برای CodeVision برای اتصال دماسنج یا رطوبت سنج به AVR
و نحوه اتصال این سنسور در Proteus رو لازم دارم
ممنون میشم اگه کسی کمک کنه
و نحوه اتصال این سنسور در Proteus رو لازم دارم
ممنون میشم اگه کسی کمک کنه
#include <mega16.h> #include <stdio.h> #include <delay.h> #include <stdlib.h> /*...............*/ void main(void) { // Declare your local variables here char str[10],lcd[10]; float tf; /* initialization*/ while (1) { // Place your code here delay_ms(1000); tf=read_adc(0); //lm35 is connected to PORTA.0(pin 40) tf=(tf*500/1023); ftoa(tf,1,str); sprintf(lcd,"Temp %2s \xdfC",str); lcd_clear(); lcd_gotoxy(0,0); puts(lcd); }; }
#include <mega16.h> #include <stdio.h> #include <delay.h> #include <stdlib.h> /*............*/ // Declare your global variables here float T1,T2; bit edge=0; // External Interrupt 0 service routine interrupt [EXT_INT0] void ext_int0_isr(void) { // Place your code here if (edge) { T2=TCNT1; TCNT1=0; // INT0 Mode: Falling Edge MCUCR=0x02; edge=0; }else { T1=TCNT1; TCNT1=0; // INT0 Mode: Rising Edge MCUCR=0x03; edge=1; } } void main(void) { // Declare your local variables here float dc; float t; char strt[16],str[8]; /*............*/ while (1) { // Place your code here delay_ms(1000); dc=T1/(T1+T2); t=(dc-0.32)/0.0047; lcd_clear(); ftoa(t,2,str); sprintf(strt,"%s \XDF C",str); lcd_puts(strt); }; }
دیدگاه