센서 > LM35-애노드 FND

TODAY459 TOTAL2,679,166
사이트 이용안내
Login▼/회원가입
최신글보기 질문게시판 기술자료 동영상강좌

아두이노 센서 ATMEGA128 PWM LED 초음파 AVR 블루투스 LCD UART 모터 적외선


BASIC4MCU | 센서 | 온습도센서 | LM35-애노드 FND

페이지 정보

작성자 키트 작성일2017-08-29 11:45 조회1,863회 댓글0건

본문

2093095301_8PwhxXg6_LM35-25BE25D625B325EB25B525E5_FND.GIF3Ftype3Dw740


//
//[lcd]       [AVR PortE]
//RS (pin4) -----  bit 0
//RD (pin 5) ----- bit 1
//EN (pin 6) ----- bit 2
//사용안함         bit 3
//DB4 (pin 11) --- bit 4
//DB5 (pin 12) --- bit 5
//DB6 (pin 13) --- bit 6
//DB7 (pin 14) --- bit 7
#include
#include
#include
//
unsigned char fnd_table[10]={0xC0,0xF9,0xA4,0xB0,0x99,0x92,0x82,0xF8,0x80,0x90};
unsigned int adc_value, temp=0, fnd_cnt=0;
char fnd_buf[4];
//
interrupt [TIM0_COMP] void timer0_comp_isr(void){ // 매치 인터럽트
    PORTA=0x0F;
    switch(fnd_cnt){
        case 0: PORTC=fnd_table[fnd_buf[0]]; PORTA=~1; break;
        case 1: PORTC=fnd_table[fnd_buf[1]]; PORTA=~2; break;
        case 2: PORTC=fnd_table[fnd_buf[2]]; PORTA=~4; break;
        case 3: PORTC=fnd_table[fnd_buf[3]]; PORTA=~8; break;
    }
    if(++fnd_cnt>3)fnd_cnt=0;
}
//
void main(void){
    float temp_f;
    DDRA=0x0F;  DDRC=0xFF;
    TCCR0=0x0D; OCR0=249;  TIMSK=2;  //16000000/  64/(1+249)= 1000Hz=1ms
    ADCSRA=0xE7;
    SREG=0x80;
    while(1){
        delay_ms(1);
        adc_value=ADCW;
        temp_f=(float)adc_value * 1000.0 / 1023.0;
        temp=(int)temp_f;
        fnd_buf[0]=temp/1000;
        fnd_buf[1]=(temp/100)%10;
        fnd_buf[2]=((temp/10)%10);
        fnd_buf[3]=temp%10;
    }
}
 
 

 

댓글 0

조회수 1,863

등록된 댓글이 없습니다.

센서HOME > 센서 > 전체 목록

게시물 검색

2022년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2021년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2020년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2019년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
2018년 1월 2월 3월 4월 5월 6월 7월 8월 9월 10월 11월 12월
Privacy Policy
MCU BASIC ⓒ 2020
모바일버전으로보기