Visualizza un messaggio singolo
Vecchio 15-11-2015, 14:55   #1
marco3020
Ciclide
 
L'avatar di marco3020
 
Registrato: Feb 2011
Città: milano
Azienda: no
Acquariofilo: Marino
N° Acquari: 1
Età : 39
Messaggi: 1.897
Foto: 0 Albums: 0
Post "Grazie" / "Mi Piace"
Grazie (Dati):
Grazie (Ricev.):
Mi piace (Dati):
Mi piace (Ricev.):
Mentioned: 7 Post(s)
Feedback 7/100%
Invia un messaggio tramite Skype a marco3020

Annunci Mercatino: 0
Programmazione ARDUINO per acquario

Buongiorno mi servirebbe una mano per programmare il mio arduino 2560 per creare un menu che mi faccia fare il cambio acqua, e la sospensione per 10 minuti della pompa come posso fare? per ora ho questo:

[CODE] #include
#include
#include
#include
#include
#include
#include
#include
#include
#include

int rele5 = 43; // pin a cui è connesso il LED
boolean acceso = false;

byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
IPAddress ip( 192, 168, 1, 6 );
EthernetServer server(80);



PCF8574_HD44780_I2C lcd(0x3F, 20, 4);

long Pompa_Accesa_in_data=0;
const unsigned long quanto_tempo_deve_restare_accesa_la_pompa = 300000;
long inizio_accensione_arduino= 0;
unsigned long quanto_tempo_deve_restare_spento_skim_avvio_arduin o = 300000;
int pompa_spenta =0;

int oraAlba = 9;
int minAlba = 10;
long albas;
int durataAlbas = 720;
int oraTramonto = 17;
int minTramonto = 10;
long tramontos;
int durataTramontos = 720;
long nows;
int delayR = 0;
int delayG = 120;
int delayB = 240;
int delayUV = 360;
int delayW = 360;

//LED
int pinR = 2;
int pinG = 3;
int pinB = 4;
int pinW = 5;
int pinUV = 6;

//RELE
float rele1 = 35;
float rele2 = 37;
int rele3 = 39;
int rele4 = 41;

int rele6 = 45;
int rele7 = 47;


//menu

int Menu=0; // VARIABILE CHE IDENTIFICA IL MENU' IN USO

const int buttonPingiu = 22; // pin Giu
const int buttonPinsu= 24; // pin Su
const int buttonPinok = 26; // pin OK
const int buttonPinPiu = 30; // pin modifica più
const int buttonPinMeno = 32; // pin modifica meno

int lastButtonokState = LOW; // the previous reading from the Enter input pin
int lastButtongiuState = LOW; // the previous reading from the Esc input pin
int lastButtonsuState = LOW; // the previous reading from the Left input pin
int lastButtonPiuState = LOW; //
int lastButtonMenoState = LOW; //

long lastEnterDebounceTime = 0; // the last time the output pin was toggled
long lastEscDebounceTime = 0; // the last time the output pin was toggled
long lastLeftDebounceTime = 0; // the last time the output pin was toggled
long lastRightDebounceTime = 0; // the last time the output pin was toggled
long debounceDelay = 500; // the debounce time

//Variabili del menu
MenuBackend menu = MenuBackend(menuUseEvent,menuChangeEvent);

void menuUseEvent(MenuUseEvent used)
{

Serial.println("menuUseEvent found Dealy (D)");
}



void menuChangeEvent(MenuChangeEvent changed)
{
Serial.print("Menu change ");
Serial.print(changed.from.getName());
Serial.print(" ");
Serial.println(changed.to.getName());
}


// MENU' IMPOSTAZIONI
MenuItem menu1Item3 = MenuItem("Item3");
MenuItem menuData=MenuItem("Data/Ora");
MenuItem menuOra=MenuItem("Ora");



char buffer1[20];
char buffer2[20];

//ALLARMI
float riscaldatore = 22.0; // allerta temperatura acqua bassa
float alertacqua = 27.0; // ventola tangenziale
float alertplafo = 44.0; // alerta plafoniera temperatura troppo alta
float tempSoglia = 38.0; //temperatura ventole plafo

#define ONE_WIRE_BUS 7
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
DeviceAddress tmp_address;
float temp0=0;
float temp1=0;
int numberOfDevices;




void setup() {

pinMode(rele1,OUTPUT);
pinMode(rele2, OUTPUT);
pinMode(rele3, OUTPUT);
pinMode(rele4,OUTPUT);
pinMode(rele5,OUTPUT);
pinMode(rele6,OUTPUT);
pinMode(rele7,OUTPUT);

digitalWrite(rele1,LOW);
digitalWrite( rele2, LOW);
digitalWrite( rele3, HIGH );
digitalWrite(rele4, LOW);
digitalWrite(rele5,0);
digitalWrite(rele6, LOW);
digitalWrite(rele7, LOW);

//BUTTON
pinMode(buttonPinMeno, INPUT);
pinMode(buttonPinPiu, INPUT);
pinMode(buttonPinok, INPUT);
pinMode(buttonPinsu, INPUT);




Serial.begin(9600);

Wire.begin();

sensors.begin();
Ethernet.begin(mac, ip);
server.begin();
Serial.print("server is at ");
Serial.println(Ethernet.localIP());
setSyncProvider(RTC.get); // the function to get the time from the RTC
if(timeStatus() != timeSet)
Serial.println("Unable to sync with the RTC");
else
Serial.println("RTC has set the system time");

lcd.init(); // LCD Initialization
lcd.backlight( ); // Backlight ON
lcd.clear(); // Clear the display

numberOfDevices = 1;

pinMode(pinR, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinW, OUTPUT);
pinMode(pinUV, OUTPUT);



inizio_accensione_arduino= millis();

}

void loop()
{

if (millis() >= (quanto_tempo_deve_restare_spento_skim_avvio_ardui no + inizio_accensione_arduino)) {
digitalWrite(rele3, LOW);
}






case 0:
if ( digitalRead( buttonMeno ) == HIGH || ( digitalRead( buttonPiu )) == HIGH) {
time = millis();
}


// prendo ora attuale
DateTime now = RTC.get();
sprintf(buffer1, "%02d:%02d:%02d", now.hour(), now.minute(), now.second());
lcd.setCursor(0,0);
lcd.print( buffer1 );

sprintf(buffer2, "%02d/%02d/%d", now.day(), now.month(), now.year());
lcd.setCursor(0,1);
lcd.print( buffer2 );
Serial.println(buffer1);
Serial.println(buffer2);

// Richiesta temperatura
sensors.requestTemperatures(); // Comando per misurare la temp.
temp0 = sensors.getTempCByIndex(0);
lcd.setCursor(0,2); // Colonna 0, Riga 2
lcd.print("acqua:");
lcd.setCursor (6, 2);
lcd.print(temp0);

temp1 = sensors.getTempCByIndex(1);
lcd.setCursor (0,3); //Colonna 0, Riga 3
lcd.print("plafo:");
lcd.setCursor (6,3);
lcd.print(temp1);

lcd.setCursor(12,1); // Colonna 0, Riga 0
lcd.print("feed:");

lcd.setCursor(12,2); // Colonna 0, Riga 0
lcd.print("cambio:");

/* if (millis()>=(Pompa_Accesa_in_data + quanto_tempo_deve_restare_accesa_la_pompa))
{
digitalWrite(rele5,0);
Pompa_Accesa_in_data = millis();
{
*/

//pompa_Spenta ==digitalRead (rele5);

// Vengono ascoltati nuovi client
EthernetClient client = server.available();
if (client) {
Serial.println("new client");
// Finisce una richiesta HTTP
boolean currentLineIsBlank = true;
String postText ="";
while (client.connected()) {
if (client.available()) {
char c = client.read();
if(postText.length()
__________________

Ultima modifica di marco3020; 17-11-2015 alle ore 18:13. Motivo: Aiuto a creare menu con arduino
marco3020 non è in linea   Rispondi quotando
 
Page generated in 0,16699 seconds with 16 queries