Download complete library here
// *************** LM75 module by Berty *************** #include#include #include "DC_Defines.h" #include "iic.c" char read_temperature(void) { unsigned char Tmpl,Tmph,Err; I2C_Start(); Write_I2C_Byte(0x91); Err=I2C_Ack(); // Check for acknowledge from I2C device Tmph=Read_I2C_Byte(); I2C_Rack(); Tmpl=Read_I2C_Byte(); I2C_Clock(); // Clock I2C bit *** No ACK *** // I2C_Stop(); // Set I2C Stop condition if (Err==1) {return 0xFF;} else {return Tmph;}; } void main(void) { unsigned char temperature_t; DDRD = 0xFF; /* output */ while (1) { temperature_t=read_temperature(); PORTD=~temperature_t; haltb(); haltb(); haltb(); haltb(); haltb(); haltb(); } }
Back to my home page
Last updated January, 2010