Плата модуля в формате lay
// LM75 + DS1307 // Код из видео http://youtu.be/ZJ123KbrXmY // #include <Wire.h> #include <LiquidCrystal.h> #define DS1307_I2C_ADDRESS 0x68 #define LM75_I2C_ADDRESS 0b1001000 // 1001 A0 A1 A2 LiquidCrystal lcd(8, 9, 4, 5, 6, 7); byte gradus[8] = { 0b00110, 0b01001, 0b01001, 0b00110, 0b00000, 0b00000, 0b00000, 0b00000 }; ///// часы .. byte decToBcd(byte val){ return ( (val/10*16) + (val%10) ); } byte bcdToDec(byte val){ return ( (val/16*10) + (val%16) ); } void setDateDs1307(byte second, // 0-59 byte minute, // 0-59 byte hour, // 1-23 byte dayOfWeek, // 1-7 byte dayOfMonth, // 1-28/29/30/31 byte month, // 1-12 byte year) // 0-99 { Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.write(0); Wire.write(decToBcd(second)); Wire.write(decToBcd(minute)); Wire.write(decToBcd(hour)); Wire.write(decToBcd(dayOfWeek)); Wire.write(decToBcd(dayOfMonth)); Wire.write(decToBcd(month)); Wire.write(decToBcd(year)); Wire.endTransmission(); } void getDateDs1307(byte *second, byte *minute, byte *hour, byte *dayOfWeek, byte *dayOfMonth, byte *month, byte *year) { Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.write(0); Wire.endTransmission(); Wire.requestFrom(DS1307_I2C_ADDRESS, 7); *second = bcdToDec(Wire.read() & 0x7f); *minute = bcdToDec(Wire.read()); *hour = bcdToDec(Wire.read() & 0x3f); *dayOfWeek = bcdToDec(Wire.read()); *dayOfMonth = bcdToDec(Wire.read()); *month = bcdToDec(Wire.read()); *year = bcdToDec(Wire.read()); } ///// температура .. float getTempLM75(){ float val; Wire.beginTransmission(LM75_I2C_ADDRESS); Wire.write(0x00); Wire.endTransmission(); Wire.requestFrom(LM75_I2C_ADDRESS, 2); while(Wire.available() < 2); byte msb = Wire.read(); byte lsb = Wire.read(); if (msb < 0x80) val=((msb*10)+(((lsb&0x80)>>7)*5)); else{ val=((msb*10)+(((lsb&0x80)>>7)*5)); val=-(2555.0-val); } return val/10; } void setup() { Wire.begin(); lcd.createChar(1, gradus); lcd.begin(16, 2); lcd.clear(); /* // установка часов byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; second = 30; minute = 0; hour = 14; dayOfWeek = 3; // день недели dayOfMonth = 1; // день month = 4; year = 14; setDateDs1307(second, minute, hour, dayOfWeek, dayOfMonth, month, year); */ } void loop() { byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; char week[8][10] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}; getDateDs1307(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); // lcd.clear(); lcd.setCursor(1, 0); if (hour < 10) lcd.print("0"); lcd.print(hour); lcd.print(":"); if (minute < 10) lcd.print("0"); lcd.print(minute); // lcd.print(":"); // if (second < 10) lcd.print("0"); // lcd.print(second); lcd.setCursor(8, 0); lcd.print(week[dayOfMonth]); lcd.print(" "); lcd.setCursor(0, 1); if (dayOfMonth < 10) lcd.print("0"); lcd.print(dayOfMonth); lcd.print("/"); if (month < 10) lcd.print("0"); lcd.print(month); lcd.print("/"); if (year < 10) lcd.print("0"); lcd.print(year); lcd.print(" "); lcd.print(int(getTempLM75())); lcd.write(1); lcd.print("C"); } ////// конец
также с LM75 можно работать при помощи библиотеки https://github.com/thefekete/LM75