реклама на сайте
подробности

 
 
> DS1621_Atmega32_LCD_16x2, не работает вывод температуры на LCD
RED_BULLok
сообщение Apr 6 2008, 10:00
Сообщение #1


Участник
*

Группа: Свой
Сообщений: 58
Регистрация: 27-03-08
Из: Беларусь, Минск
Пользователь №: 36 275



Здравствуйте. Много тем встретил на форуме про датчик и работу с ним, но чтото никак не могу разобраться с выводом температуры на LCD.

в CV есть готовые библиотеки для этого датчика, так что остановился на этой программе.
Моделирую работу в Proteus 7.1 sp2

код

#include <mega32.h>

// I2C Bus functions
#asm
.equ __i2c_port=0x15 ;PORTC
.equ __sda_bit=1
.equ __scl_bit=0
#endasm

#include <i2c.h>

// DS1621 Thermometer/Thermostat functions
#include <ds1621.h>

// Alphanumeric LCD Module functions

#asm
.equ __lcd_port=0x1B ;PORTA
#endasm

#include <lcd.h>
#include <stdio.h>
#include <math.h>

// Declare your global variables here
char display_buffer[33];


void main(void)
{

// Declare your local variables here
int t0;

// I2C Bus initialization
i2c_init();

// DS1621 Thermometer/Thermostat initialization
// tlow: 10°C
// thigh: 20°C
// Tout polarity: 1
ds1621_init(0,10,20,1);

// LCD module initialization
lcd_init(16);

while (1)
{
t0=ds1621_temperature_10(0);
// Place your code here
sprintf(display_buffer,"t0=%-i.%-u%cC",
t0/10,abs(t0%10),0xdf);

/* display the temperatures */
lcd_clear();
lcd_puts(display_buffer);
};
Прикрепленный файл  proteus.bmp ( 88.81 килобайт ) Кол-во скачиваний: 87
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 чел. читают эту тему (гостей: 1, скрытых пользователей: 0)
Пользователей: 0

 


RSS Текстовая версия Сейчас: 19th July 2025 - 03:04
Рейтинг@Mail.ru


Страница сгенерированна за 0.02836 секунд с 7
ELECTRONIX ©2004-2016