30-11-2016, 00:41
Witam
Mam zbudowany termometr czterokanałowy z obsługą 2 wyświetlaczy . Wszystko chodziło dobrze , lecz musiałem dodać wyzwalanie pinu cyfrowego po odpowiednim czasie :
Po wstawieniu tego do void setup wyświetlacze nie pokazują już niczego - tylko świecą . Gdzie popełniłem błąd ?
Program przed modyfikacją wyglądał tak:
A po modyfikacji , już nie działający wygląda tak
Mam zbudowany termometr czterokanałowy z obsługą 2 wyświetlaczy . Wszystko chodziło dobrze , lecz musiałem dodać wyzwalanie pinu cyfrowego po odpowiednim czasie :
Kod:
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
delay(1800000 );
digitalWrite(3, LOW);
Po wstawieniu tego do void setup wyświetlacze nie pokazują już niczego - tylko świecą . Gdzie popełniłem błąd ?
Program przed modyfikacją wyglądał tak:
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);
LiquidCrystal_I2C lcd2(0x26, 2, 1, 0, 4, 5, 6, 7);
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress P1 = { 0x28, 0xFF, 0xB6, 0x35, 0xB0, 0x15, 0x3, 0x1F };
DeviceAddress P2 = { 0x28, 0xFF, 0xF5, 0x31, 0xB1, 0x15, 0x1, 0xA1 };
DeviceAddress P3 = { 0x28, 0xFF, 0x42, 0x2F, 0xB0, 0x15, 0x3, 0x85 };
DeviceAddress P4 = { 0x28, 0xFF, 0xDE, 0x2F, 0xB1, 0x15, 0x1, 0x4 };
void setup()
{
Serial.begin(9600);
sensors.begin();
Wire.begin();
lcd.begin(16, 2);
lcd2.begin(20,4);
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(HIGH);
lcd2.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd2.setBacklight(HIGH);
}
void loop() {
sensors.requestTemperatures();
int tempC1 = sensors.getTempC(P1);
int tempC2 = sensors.getTempC(P2);
int tempC3 = sensors.getTempC(P3);
int tempC4 = sensors.getTempC(P4);
lcd.setCursor (0, 0);
lcd.write("PIEC ");
lcd.print(tempC1, 1);
lcd.write(byte(223));
lcd.setCursor (9, 0);
lcd.write("WYJ ");
lcd.print(tempC2, 1);
lcd.write(byte(223));
lcd.setCursor (0, 1);
lcd.write("POWR ");
lcd.print(tempC3, 1);
lcd.write(byte(223));
lcd.setCursor (9, 1);
lcd.write("MIE ");
lcd.print(tempC4, 1);
lcd.write(byte(223));
sensors.requestTemperatures();{
float tempC1 = sensors.getTempC(P1);
float tempC2 = sensors.getTempC(P2);
float tempC3 = sensors.getTempC(P3);
float tempC4 = sensors.getTempC(P4);
lcd2.setCursor (0, 0);
lcd2.write("TEMP.PIEC ");
lcd2.print(tempC1, 1);
lcd2.write(byte(223));
lcd2.setCursor (0, 1);
lcd2.write("WYJSCIE PIEC ");
lcd2.print(tempC2, 1);
lcd2.write(byte(223));
lcd2.setCursor (0, 2);
lcd2.write("POWROT WODY ");
lcd2.print(tempC3, 1);
lcd2.write(byte(223));
lcd2.setCursor (0, 3);
lcd2.write("MIESZAJACY ");
lcd2.print(tempC4, 1);
lcd2.write(byte(223));
}
}
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);
LiquidCrystal_I2C lcd2(0x26, 2, 1, 0, 4, 5, 6, 7);
#define ONE_WIRE_BUS 4
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress P1 = { 0x28, 0xFF, 0xB6, 0x35, 0xB0, 0x15, 0x3, 0x1F };
DeviceAddress P2 = { 0x28, 0xFF, 0xF5, 0x31, 0xB1, 0x15, 0x1, 0xA1 };
DeviceAddress P3 = { 0x28, 0xFF, 0x42, 0x2F, 0xB0, 0x15, 0x3, 0x85 };
DeviceAddress P4 = { 0x28, 0xFF, 0xDE, 0x2F, 0xB1, 0x15, 0x1, 0x4 };
void setup()
{
Serial.begin(9600);
sensors.begin();
Wire.begin();
lcd.begin(16, 2);
lcd2.begin(20,4);
lcd.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd.setBacklight(HIGH);
lcd2.setBacklightPin(BACKLIGHT_PIN, POSITIVE);
lcd2.setBacklight(HIGH);
pinMode(3, OUTPUT);
digitalWrite(3, HIGH);
delay(1800000 );
digitalWrite(3, LOW);
}
void loop() {
sensors.requestTemperatures();
int tempC1 = sensors.getTempC(P1);
int tempC2 = sensors.getTempC(P2);
int tempC3 = sensors.getTempC(P3);
int tempC4 = sensors.getTempC(P4);
lcd.setCursor (0, 0);
lcd.write("PIEC ");
lcd.print(tempC1, 1);
lcd.write(byte(223));
lcd.setCursor (9, 0);
lcd.write("WYJ ");
lcd.print(tempC2, 1);
lcd.write(byte(223));
lcd.setCursor (0, 1);
lcd.write("POWR ");
lcd.print(tempC3, 1);
lcd.write(byte(223));
lcd.setCursor (9, 1);
lcd.write("MIE ");
lcd.print(tempC4, 1);
lcd.write(byte(223));
lcd2.setCursor (0, 0);
lcd2.write("TEMP.PIEC ");
lcd2.print(tempC1, 1);
lcd2.write(byte(223));
lcd2.setCursor (0, 1);
lcd2.write("WYJSCIE PIEC ");
lcd2.print(tempC2, 1);
lcd2.write(byte(223));
lcd2.setCursor (0, 2);
lcd2.write("POWROT WODY ");
lcd2.print(tempC3, 1);
lcd2.write(byte(223));
lcd2.setCursor (0, 3);
lcd2.write("MIESZAJACY ");
lcd2.print(tempC4, 1);
lcd2.write(byte(223));
}