Код: Выделить всё
#include <mega16.h>
#include <delay.h>
#asm
.equ __w1_port=0x15 ;PORTC
.equ __w1_bit=3
#endasm
#include <1wire.h>
#include <ds18b20.h>
#asm
.equ __lcd_port=0x1B ;PORTA
#endasm
#include <lcd.h>
#include <stdio.h>
#include <stdlib.h>
char lcd_buf[17];
;
void main(void)
{
float templcd;
int tempuart;
unsigned char i=0;
char t[3];
int m=0;
lcd_init(16);
w1_init();
ds18b20_init(0,-20,50,DS18B20_12BIT_RES);
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
PINB=0x00;
DDRB=0x00;
lcd_putsf("Loading");
while(1)
{
delay_ms(500);
i++;
lcd_gotoxy(i-1,1);
lcd_putchar(0xff);
if(i==16){break;}
};
while (1)
{
if (PINB.0==1){
delay_ms(1000);
if (PINB.0==1){
m=m+1;
}
};
templcd=ds18b20_temperature(0);
tempuart=ds18b20_temperature(0);
sprintf(lcd_buf,"t=%.1f\xdfC",templcd);
if(tempuart>1000)
{
tempuart=4096-tempuart;
tempuart=-tempuart;
}
printf("%X",tempuart);
lcd_clear();
lcd_gotoxy(0,0);
lcd_puts(lcd_buf);
// тест меню
lcd_gotoxy(0,1);
lcd_putsf("punkt=");
itoa (m, t);
lcd_gotoxy(6,1);
lcd_puts(t);
// тест меню
delay_ms(1000);
};
}
- Вложения
-
- Прога.zip
- (111.33 КБ) 129 скачиваний

