• Witaj na Forum Arduino Polska! Zapraszamy do rejestracji!
  • Znajdziesz tutaj wiele informacji na temat hardware / software.
Witaj! Logowanie Rejestracja


Ocena wątku:
  • 0 głosów - średnia: 0
  • 1
  • 2
  • 3
  • 4
  • 5
Termometr cztero-czujnikowy
#2
Spróbuj coś takiego:
Kod:
#include <OneWire.h>
#include <DallasTemperature.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define BACKLIGHT_PIN 3
LiquidCrystal_I2C  lcd(0x27,2,1,0,4,5,6,7);

#define ONE_WIRE_BUS 8
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);

byte temp[8] = //ikona temperatury
{
  B00100,
  B01010,
  B01010,
  B01110,
  B01110,
  B11111,
  B11111,
  B01110
};
byte stopnie[8] = //ikona stopni
{
  B01100,
  B10010,
  B10010,
  B01100,
  B00000,
  B00000,
  B00000,
  B00000
};

DeviceAddress P1 = { 0x28, 0x00, 0x00, 0x1E, 0x07, 0x00, 0x00, 0x00 }; // tu trzeba wpisać swoje adresy
DeviceAddress P2 = { 0x28, 0x00, 0x00, 0x1F, 0x07, 0x00, 0x00, 0x00 };
DeviceAddress P3 = { 0x28, 0x00, 0x00, 0x1F, 0x07, 0x00, 0x00, 0x00 };
DeviceAddress P4 = { 0x28, 0x00, 0x00, 0x1F, 0x07, 0x00, 0x00, 0x00 };

void setup()
{
 Serial.begin(115200);
sensors.begin();
Wire.begin();
 lcd.begin(16, 2);
 lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
 lcd.setBacklight(HIGH);
 lcd.createChar(0, temp);
 lcd.createChar(3, stopnie);
}
void loop(){
sensors.requestTemperatures();
float tempC1 = sensors.getTempC(P1);
float tempC2 = sensors.getTempC(P2);
float tempC3 = sensors.getTempC(P3);
float tempC4 = sensors.getTempC(P4);

  lcd.setCursor (0, 0);
  lcd.write("1");
  lcd.write(byte(0));
  lcd.print("=");
  lcd.print(tempC1, 1);
  lcd.write(byte(3));
  lcd.print("C");
 
  lcd.setCursor (10, 0);
  lcd.write("2");
  lcd.write(byte(0));
  lcd.print("=");
  lcd.print(tempC2, 1);
  lcd.write(byte(3));
  lcd.print("C");
 
  lcd.setCursor (0, 1);
  lcd.write("3");
  lcd.write(byte(0));
  lcd.print("=");
  lcd.print(tempC3, 1);
  lcd.write(byte(3));
  lcd.print("C");
 
  lcd.setCursor (10, 1);
  lcd.write("4");
  lcd.write(byte(0));
  lcd.print("=");
  lcd.print(tempC4, 1);
  lcd.write(byte(3));
  lcd.print("C");
 
}
 
Odpowiedź
  


Wiadomości w tym wątku
Termometr cztero-czujnikowy - przez maniolx - 29-12-2015, 02:57
RE: Termometr cztero-czujnikowy - przez zbyszek78 - 29-12-2015, 20:27
RE: Termometr cztero-czujnikowy - przez maniolx - 30-12-2015, 00:19
RE: Termometr cztero-czujnikowy - przez zbyszek78 - 30-12-2015, 06:25
RE: Termometr cztero-czujnikowy - przez maniolx - 30-12-2015, 13:43
RE: Termometr cztero-czujnikowy - przez zbyszek78 - 30-12-2015, 18:06
RE: Termometr cztero-czujnikowy - przez maniolx - 31-12-2015, 02:57
RE: Termometr cztero-czujnikowy - przez Lobaf - 31-12-2015, 13:13
RE: Termometr cztero-czujnikowy - przez maniolx - 02-01-2016, 01:30
RE: Termometr cztero-czujnikowy - przez Leszek - 17-03-2016, 01:32
RE: Termometr cztero-czujnikowy - przez rafal.ab - 23-10-2018, 20:32
RE: Termometr cztero-czujnikowy - przez kaczakat - 23-10-2018, 21:13

Skocz do:


Przeglądający: 1 gości