Go Down

Topic: Arduino programy (Read 2338 times) previous topic - next topic

adamko97

Apr 03, 2017, 07:42 pm Last Edit: Apr 04, 2017, 09:03 pm by adamko97
#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>

#define ONE_WIRE_BUS 4
LiquidCrystal lcd(13, 12, 3, 2, 1, 0);
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int spotrebalitrov = 0;
int porucha = 0;
int plavakmin = 5;
int plavakmax = 6;
int plavakpretecenie = 7;
int relecerpadlo = 8;
int releohrev = 9;
int tlacidloZAP_VYPcerpadlo = 10;
int tlacidloZAP_VYPohrev = 11;
int tlacidloReset = A0;
int ledZapnutecerpadlo = A1;
int ledZapnutyohrev = A2;
long casovac1 = 0;
long casovac2 = 0;
long casovac3 = 0;
int ibaraz = 1;

void setup() {
lcd.begin(16, 2);
sensors.begin();

pinMode(plavakmin, INPUT);
pinMode(plavakmax, INPUT);
pinMode(plavakpretecenie, INPUT);
pinMode(relecerpadlo, OUTPUT);
pinMode(releohrev, OUTPUT);
pinMode(tlacidloZAP_VYPcerpadlo, INPUT);
pinMode(tlacidloZAP_VYPohrev, INPUT);
pinMode(tlacidloZAP_VYPohrev, INPUT);

}

void loop() {

//ZOBRAZENIE NA DISPLEJI
if (millis() > (4000 + casovac1))
{
lcd.clear();
sensors.requestTemperatures();
lcd.setCursor(0, 1);
lcd.print("Tep.vody:");
lcd.print(sensors.getTempCByIndex(0));
lcd.print("C");
lcd.print("\337C");
lcd.setCursor(0, 0);
lcd.print("Spotr.vody:");
lcd.print(spotrebalitrov);
lcd.print("L");
casovac1 = millis();
}


if (millis() > (8000 + casovac2))
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("Poruchy:");
lcd.setCursor(0, 1);

if (porucha == 1)
{
lcd.print("Pretecenie vody");
}
if (porucha == 2)
{
lcd.print("Nizka hlad.vody");
}
if (porucha == 3)
{
lcd.print("Pomal.napus.vody");
}
if (porucha == 4)
{
lcd.print("Vysok.tep.ohrev.");
}
casovac2 = millis();
}
//ZOBRAZENIE NA DISPLEJI



//OSETRENIE VSTUPOV





//OSETRENIE VSTUPOV



//NAPUSTANIE NADRZE VODOU
if ((digitalRead(tlacidloZAP_VYPcerpadlo) == HIGH)&& (ibaraz==1)) //VYPNUTIE CERPADLA
{
digitalWrite(relecerpadlo, LOW);
analogWrite(ledZapnutecerpadlo, 255);
}

if ((digitalRead(tlacidloZAP_VYPcerpadlo) == LOW)&&(digitalRead(plavakmin) == HIGH)&&(digitalRead(plavakmax) == HIGH)) //ZAPNUTIE CERPADLA
{
digitalWrite(relecerpadlo, HIGH);
analogWrite(ledZapnutecerpadlo, 0);
}

if ((digitalRead(tlacidloZAP_VYPcerpadlo) == LOW)&&(digitalRead(plavakmin) == HIGH)&&(digitalRead(plavakmax) == LOW)) //NAPUSTENIE POLOVICE NADRZE
{
digitalWrite(relecerpadlo, HIGH);
analogWrite(ledZapnutecerpadlo, 0);
}

if ((digitalRead(tlacidloZAP_VYPcerpadlo) == LOW)&&(digitalRead(plavakmin) == LOW)&&(digitalRead(plavakmax) == LOW)) //NAPUSTENIE PLNEJ NADRZE
{
digitalWrite(relecerpadlo, LOW);
analogWrite(ledZapnutecerpadlo, 255);
}





if ((digitalRead(plavakpretecenie) == LOW)&&(relecerpadlo == HIGH)) //PRETECENIE NADRZE
{
porucha == 1;
}
else
{
porucha == 0;
}
//NAPUSTANIE NADRZE VODOU



//OVLADANIE OHREVU VODY
if ((digitalRead(tlacidloZAP_VYPohrev) == LOW)&&(digitalRead(plavakmin) == LOW))

{
digitalWrite(releohrev, HIGH);
analogWrite(ledZapnutyohrev, 0);
}
else
{
digitalWrite(releohrev, LOW);
analogWrite(ledZapnutyohrev, 255);
}
//OVLADANIE OHREVU VODY


}

Go Up