BASIC4MCU | 센서 | 기타센서 | TILT SA1 기울기센서 CLCD 표시
페이지 정보
작성자 키트 작성일2017-09-04 15:53 조회2,078회 댓글0건본문
![]() |
http://devicemart.co.kr/goods/view.php?seq=8111 |
LCD 선 연결
[LCD] [AVR PortC]
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
//*****************************************************
// TILT SA1
// 30mV/(1도)
// +-60도
//Chip type : ATmega128 : 16.000000 MHz
//*****************************************************
#include
#include
#include
#asm
.equ __lcd_port=0x15 ;PORTC
#endasm
#include
int temp_I;
float temp_F;
void main(void){
char str[30];
ADCSRA=0xE7; //프리런닝 ADC0
lcd_init(16);
while(1){
delay_ms(250);
temp_I=ADCW;
temp_F=(float)temp_I * 5.0 / 1023.0; //전압으로 변경 하고
temp_F=(temp_F-2.5) / 0.03; // 0도(2.5V)를 빼준 후에 0.03으로 나눔
lcd_clear();
lcd_gotoxy(0,0); sprintf(str,"Tilt Test Prog.");
lcd_puts(str);
lcd_gotoxy(0,1); sprintf(str,"Tilt = %.1f",temp_F); //소숫점 1자리 출력
lcd_puts(str);
}
}
//========================================
.equ __lcd_port=0x1B ;PORTA
.equ __lcd_port=0x18 ;PORTB
.equ __lcd_port=0x15 ;PORTC
.equ __lcd_port=0x12 ;PORTD
.equ __lcd_port=0x03 ;PORTE
LCD 포트 변경 시에는 위 내용만 바꿔주면 됩니다.
댓글 0
조회수 2,078등록된 댓글이 없습니다.