Hirdetés

2024. május 2., csütörtök

Gyorskeresés

Téma összefoglaló

Téma összefoglaló

  • Utoljára frissítve: 2023-03-11 00:46:52

LOGOUT.hu

Arduino hardverrel és szoftverrel foglakozó téma. Minden mikrovezérlő ami arduinoval programozható, és minden arduino program, board, és hardverrel kapcsolatos kérdések helye.

Összefoglaló kinyitása ▼

Hozzászólások

(#5100) leventekov


leventekov
csendes újonc

Sziasztok
Segitseget szeretnek kerni.

egy lampat szeretnek megadott idore kapcsolni. Be es Ki
es egy gombot mikor nem villagit be lehessen kapcsolni es ugyan azzal ki.

/*

Akvárium vezérlés

*/
#include <Wire.h>
#include <LiquidCrystal.h>
//declare variables
float tempC;
float temp2C;
int tempPin = 1;
int temp2Pin = 2;

int buttonPin = 10 ;
boolean currentState = LOW;//stroage for current button state
boolean lastState = LOW;//storage for last button state
boolean ledState = LOW;//storage for the current state of the LED (off/on

int hour;
int minute;
int second;
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

int co2Pin = 0; // co2 szelep
int regvilPin = 1; // reggeli villagita
int ledPin = 13; // ledszallag
int napalivilPin = 9; // napalivillagitas
int tap1Pin = 7; // tap 1 pumpa
int tap2Pin = 8; // tap 2 pumpa
int tap3Pin = 6; // tap 2 pumpa

void setup()
{

lcd.begin(16, 4);
Wire.begin();
pinMode(co2Pin, OUTPUT);
digitalWrite(co2Pin, LOW);
digitalWrite(napalivilPin, LOW);
pinMode(napalivilPin,OUTPUT);
digitalWrite(regvilPin, LOW);
pinMode(regvilPin, OUTPUT);
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
pinMode(tap1Pin, OUTPUT);
digitalWrite (tap1Pin, LOW);
pinMode (tap2Pin, OUTPUT);
digitalWrite (tap2Pin, LOW);
pinMode (tap3Pin, OUTPUT);
digitalWrite (tap3Pin, LOW);

pinMode(buttonPin, INPUT);//this time we will set the pin as INPUT
pinMode(ledPin, OUTPUT);
Serial.begin(9600);//initialize Serial connection

}
void loop()
{

Wire.beginTransmission(104);
Wire.write(0x00);
Wire.endTransmission();
Wire.requestFrom(104, 7);
second = Wire.read();
minute = Wire.read();
hour = Wire.read();
hour=hour/16 * 10 + hour % 16;
minute=minute/16 * 10 + minute % 16;
second=second/16 * 10 + second % 16;

lcd.setCursor(1,0);
lcd.print("Time ");
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);

tempC = analogRead(tempPin); //read the value from the sensor
tempC = (5.0 * tempC * 100.0)/1024.0; //convert the analog data to temperature
temp2C = analogRead(temp2Pin); //read the value from the sensor
temp2C = (5.0 * temp2C * 100.0)/1024.0; //convert the analog data to temperature

// print result to lcd display
lcd.setCursor(1,1);
lcd.print("Viz");
lcd.setCursor(10, 1);
lcd.print(tempC,1);
lcd.print("'C");

lcd.setCursor(1,2);
lcd.print("Szoba");
lcd.setCursor(10, 2);
lcd.print(temp2C,1);
lcd.print("'C");
lcd.setCursor(1,3);
if (hour*60+minute >= 540 && hour*60+minute <=1020 ) // CO@ adagolas kiirasa 9:00 - 17:00
{lcd.print("CO2 ADAGOLAS");}
{
lcd.print("CO2 KIKAPCSOLT");
}
if (hour*60+minute >= 1020 and hour*60+minute <= 540)
//----------------------------------------------------------------------------------
//Tápoldat 1 adagolás 7:00:00-kor 5mp

if (hour*360+minute*60+second >= 2520 and hour*360+minute*60+second <= 2522)
{digitalWrite (tap1Pin, HIGH);}
else
{digitalWrite (tap1Pin, LOW);}

//----------------------------------------------------------------------------------
//Tápoldat 2 adagolás 7:00:10-kor 5mp

if (hour*360+minute*60+second >= 2523 and hour*360+minute*60+second <= 2525)
{digitalWrite (tap2Pin, HIGH);}
else
{digitalWrite (tap2Pin, LOW);}

//----------------------------------------------------------------------------------
//Tápoldat 3 adagolás 7:00:10-kor 5mp

if (hour*360+minute*60+second >= 2526 and hour*360+minute*60+second <= 2528)
{digitalWrite (tap3Pin, HIGH);}
else
{digitalWrite (tap3Pin, LOW);}

//-----------------------------------------------------------------------------------
//CO2 vezerles: Be: 09:00 Ki: 17:00

if (hour*60+minute >= 540 && hour*60+minute <=1020 )
{digitalWrite (co2Pin, HIGH);}
else
{digitalWrite (co2Pin, LOW);}
//................................................................................
//Reggeli villagitas : Be: 11:00 Ki : 19:00

if (hour*60+minute >= 660 && hour*60+minute <= 1140)
{digitalWrite (regvilPin, HIGH);}
else
{digitalWrite (regvilPin, LOW);}

//--------------------------------------------------------------------------------
// Nappali Villagitas :Be: 14:00 Ki: 16:00

if (hour*60+minute >= 840 && hour*60+minute <= 960)
{digitalWrite (napalivilPin, HIGH);}
else
{digitalWrite (napalivilPin, LOW);}

//----------------------------------------------------------------

//................................................................................
//Esteji villagitas : Be: 11:00 Ki : 19:00

if (hour*60+minute >= 660 && hour*60+minute <= 1140)
{digitalWrite (regvilPin, HIGH);}
else
{digitalWrite (regvilPin, LOW);}

currentState = digitalRead(buttonPin);
if (currentState == HIGH && lastState == LOW){//if button has just been pressed
Serial.println("pressed");
delay(1);//crude form of button debouncing

//toggle the state of the LED
if (ledState == HIGH){
digitalWrite(ledPin, LOW);
ledState = LOW;
} else {
digitalWrite(ledPin, HIGH);
ledState = HIGH;

}

}
lastState = currentState;
}

//
KB igy nez ki

[ Szerkesztve ]

Copyright © 2000-2024 PROHARDVER Informatikai Kft.