Page 198 - 2
P. 198
{
fcount = (float)(count * 5.0 / 1023.0);
icount = (int)((fcount * 100.0 + 0.5)*100);
four = (icount/1000)%10;
three = (icount/100)%10;
two = (icount/10)%10;
one = (icount/1)%10;
}
void sleepmode()
{
ADC_fan();
}
void ADC_fan()
{
if(icount<=1027) {speed = 0;}
else if(icount>1027&&icount<=1271) {speed = 100;}
else if(icount>1271&&icount<=1467) {speed = 170;} // 20, 25 ,29 도 - 1027,1271,1467
else if(icount>1467) {speed = 255;}
}
void init_LCD(void) // LCD 초기화 함수
{
delay_ms(15);
LCD_cmd_write(0x38); // 기능 설정(Function Set)
delay_ms(5); // 4.1ms 이상 기다림
LCD_cmd_write(0x38); // 기능 설정(Function Set)
delay_us(100); // 100us 이상 기다림
LCD_cmd_write(0x38); // 기능 설정(Function Set)
LCD_cmd_write(0x08); // 디스플레이 OFF
LCD_cmd_write(0x01); // 표시 클리어
LCD_cmd_write(0x06); // 엔트리모드 디스플레이 우로 시프트. (Shift)
LCD_cmd_write(0x0C); // 디스플레이 ON
}
void LCD_KEY_DISP(void)
{
LCD_cmd_write(LINE1); // LCD 의 첫 번째 줄을 선택하기 위한 기능
LCD_String("<SMART FAN>"); // 문자열 LCD_String() 로 전송
LCD_cmd_write(LINE2); // LCD 의 두 번째 줄을 선택하기 위한 기능
LCD_String("ONDO =>"); // 문자열 LCD_String() 로 전송
}
void AppInventor()
{
if(rx==0x02)
{
motor_spin=0;
PORTB.0=0;
- 198 -