aiuto a programmare arduino mega 2560
Buongiorno a tutti sto finendo una plafoniera che è controllata da arduino ma non so scrivere il programma chi mi aiuta? la plafoniera ha 9 canali e devo farli fare ste cose: alba e tramonto, data e ora, temperatura plafo per accensione ventole, e con il tastierino devo aumentare e abbassare ore luce e intensità. grazie a tutti in anticipo
|
prova a vedere negli articoli sul Portale, magari ti aiutano, ci sono alcuni esempi.
|
ho cercato invano nessun programma adatto a me :( aiutatemi per favore :(
|
Perdonami ma se non sei esperto di elettronica/programmazione lascia perdere. Vai dietro alla corrente di casa che ha un voltaggio elevato, se non sai quello che fai vai incontro a diversi pericoli! E comunque in rete esistono tanti progetti già fatti, guarda su youtube!
Inviato dal mio iPhone utilizzando Tapatalk |
mi serve lo sketch per favore
|
Se conosci almeno le basi della programmazione arduino, per gestire alba e tramonto potresti utilizzare la classe che ho creato qualche tempo fa:
Classe gestione plafoniera |
Quote:
per me se dici: deve fare alba e tramonto e orologio e non riesci a mettere giu un minimo di programma è perchè ti mancano le basi...quindi cerchi qualcuno che lo faccia per te, non ci sono problemi ma almeno dillo. IMHO Poi cosa usi? Hai un display?quale? hai dell'ulteriore hw?quale? almeno metti in condizione chi ti può aiutare, di farlo. |
Grz quello che mi serviva :) ora mi serve capire come fare 8 canali e come dirli di accendere le ventole quando serve grz
------------------------------------------------------------------------ Allora io ho un semplice display lcd 16x2 rtc ds1307, 7 pulsanti da collegare con il display per comandare le cose da display |
buongiorno su internet ho trovato questo chi mi aiuta sistemarlo per poterlo usare a mio piacimento?
include the libraries: #include <LiquidCrystal.h> #include <Wire.h> #include <Button.h> #include <EEPROM.h> #include <EEPROMVar.h> /**** Define Variables & Constants ****/ /**************************************/ // set the RTC's I2C address #define DS1307_I2C_ADDRESS 0x68 // create the LCD LiquidCrystal lcd(8, 7, 5, 4, 16, 2); // set up backlight int bkl = 6; // backlight pin byte bklIdle = 10; // PWM value for backlight at idle byte bklOn = 70; // PWM value for backlight when on int bklDelay = 10000; // ms for the backlight to idle before turning off unsigned long bklTime = 0; // counter since backlight turned on // create the menu counter int menuCount = 1; int menuSelect = 0; //create the plus and minus navigation delay counter with its initial maximum of 250. byte btnMaxDelay = 200; byte btnMinDelay = 25; byte btnMaxIteration = 5; byte btnCurrIteration; //create manual override variables boolean override = false; byte overmenu = 0; int overpercent = 0; // create the buttons Button menu = Button(12,PULLDOWN); Button select = Button(13,PULLDOWN); Button plus = Button(14,PULLDOWN); Button minus = Button(15,PULLDOWN); // LED variables. These control the behavior of lighting. Change these to customize behavoir int minCounter = 0; // counter that resets at midnight. int oldMinCounter = 0; // counter that resets at midnight. int oneLed = 9; // pin for channel 1 int twoLed = 10; // pin for channel 2 int threeLed = 11; // pin for channel 3 int fourLed = 3; // pin for channel 4 int oneVal = 0; // current value for channel 1 int twoVal = 0; // current value for channel 2 int threeVal = 0; // current value for channel 3 int fourVal = 0; // current value for channel 4 // Variables making use of EEPROM memory: EEPROMVar<int> oneStartMins = 750; // minute to start this channel. EEPROMVar<int> onePhotoPeriod = 720; // photoperiod in minutes for this channel. EEPROMVar<int> oneMax = 100; // max intensity for this channel, as a percentage EEPROMVar<int> oneFadeDuration = 60; // duration of the fade on and off for sunrise and sunset for // this channel. EEPROMVar<int> twoStartMins = 810; EEPROMVar<int> twoPhotoPeriod = 600; EEPROMVar<int> twoMax = 100; EEPROMVar<int> twoFadeDuration = 60; EEPROMVar<int> threeStartMins = 810; EEPROMVar<int> threePhotoPeriod = 600; EEPROMVar<int> threeMax = 100; EEPROMVar<int> threeFadeDuration = 60; EEPROMVar<int> fourStartMins = 480; EEPROMVar<int> fourPhotoPeriod = 510; EEPROMVar<int> fourMax = 100; EEPROMVar<int> fourFadeDuration = 60; // variables to invert the output PWM signal, // for use with drivers that consider 0 to be "on" // i.e. buckpucks. If you need to provide an inverted // signal on any channel, set the appropriate variable to true. boolean oneInverted = false; boolean twoInverted = false; boolean threeInverted = false; boolean fourInverted = false; /* int oneStartMins = 1380; // minute to start this channel. int onePhotoPeriod = 120; // photoperiod in minutes for this channel. int oneMax = 100; // max intensity for this channel, as a percentage int oneFadeDuration = 60; // duration of the fade on and off for sunrise and sunset for // this channel. int twoStartMins = 800; int twoPhotoPeriod = 60; int twoMax = 100; int twoFadeDuration = 15; int threeStartMins = 800; int threePhotoPeriod = 60; int threeMax = 100; int threeFadeDuration = 30; int fourStartMins = 800; int fourPhotoPeriod = 120; int fourMax = 100; int fourFadeDuration = 60; */ /****** RTC Functions ******/ /***************************/ // Convert decimal numbers to binary coded decimal byte decToBcd(byte val) { return ( (val/10*16) + (val%10) ); } // Convert binary coded decimal to decimal numbers byte bcdToDec(byte val) { return ( (val/16*10) + (val%16) ); } // Sets date and time, starts the clock void setDate(byte second, // 0-59 byte minute, // 0-59 byte hour, // 1-23 byte dayOfWeek, // 1-7 byte dayOfMonth, // 1-31 byte month, // 1-12 byte year) // 0-99 { Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.send(0); Wire.send(decToBcd(second)); Wire.send(decToBcd(minute)); Wire.send(decToBcd(hour)); Wire.send(decToBcd(dayOfWeek)); Wire.send(decToBcd(dayOfMonth)); Wire.send(decToBcd(month)); Wire.send(decToBcd(year)); Wire.endTransmission(); } // Gets the date and time void getDate(byte *second, byte *minute, byte *hour, byte *dayOfWeek, byte *dayOfMonth, byte *month, byte *year) { Wire.beginTransmission(DS1307_I2C_ADDRESS); Wire.send(0); Wire.endTransmission(); Wire.requestFrom(DS1307_I2C_ADDRESS, 7); *second = bcdToDec(Wire.receive() & 0x7f); *minute = bcdToDec(Wire.receive()); *hour = bcdToDec(Wire.receive() & 0x3f); *dayOfWeek = bcdToDec(Wire.receive()); *dayOfMonth = bcdToDec(Wire.receive()); *month = bcdToDec(Wire.receive()); *year = bcdToDec(Wire.receive()); } /****** LED Functions ******/ /***************************/ //function to set LED brightness according to time of day //function has three equal phases - ramp up, hold, and ramp down int setLed(int mins, // current time in minutes int ledPin, // pin for this channel of LEDs int start, // start time for this channel of LEDs int period, // photoperiod for this channel of LEDs int fade, // fade duration for this channel of LEDs int ledMax, // max value for this channel boolean inverted // true if the channel is inverted ) { int val = 0; //fade up if (mins > start || mins <= start + fade) { val = map(mins - start, 0, fade, 0, ledMax); } //fade down if (mins > start + period - fade && mins <= start + period) { val = map(mins - (start + period - fade), 0, fade, ledMax, 0); } //off or post-midnight run. if (mins <= start || mins > start + period) { if((start+period)%1440 < start && (start + period)%1440 > mins ) { val=map((start+period-mins)%1440,0,fade,0,ledMax); } else val = 0; } if (val > ledMax) {val = ledMax;} if (val < 0) {val = 0; } if (inverted) {analogWrite(ledPin, map(val, 0, 100, 255, 0));} else {analogWrite(ledPin, map(val, 0, 100, 0, 255));} if(override){val=overpercent;} return val; } /**** Display Functions ****/ /***************************/ //button hold function int btnCurrDelay(byte curr) { if(curr==btnMaxIteration) { btnCurrIteration = btnMaxIteration; return btnMaxDelay; } else if(btnCurrIteration ==0) { return btnMinDelay; } else { btnCurrIteration--; return btnMaxDelay; } } // format a number of minutes into a readable time (24 hr format) void printMins(int mins, //time in minutes to print boolean ampm //print am/pm? ) { int hr = (mins%1440)/60; int mn = mins%60; if(hr<10){ lcd.print(" "); } lcd.print(hr); lcd.print(":"); if(mn<10){ lcd.print("0"); } lcd.print(mn); } // format hours, mins, secs into a readable time (24 hr format) void printHMS (byte hr, byte mn, byte sec //time to print ) { if(hr<10){ lcd.print(" "); } lcd.print(hr, DEC); lcd.print(":"); if(mn<10){ lcd.print("0"); } lcd.print(mn, DEC); lcd.print(":"); if(sec<10){ lcd.print("0"); } lcd.print(sec, DEC); } void ovrSetAll(int pct){ analogWrite(oneLed,map(pct,0,100,0,255)); analogWrite(twoLed,map(pct,0,100,0,255)); analogWrite(threeLed,map(pct,0,100,0,255)); analogWrite(fourLed,map(pct,0,100,0,255)); } /**** Setup ****/ /***************/ void setup() { Wire.begin(); pinMode(bkl, OUTPUT); lcd.begin(16, 2); digitalWrite(bkl, HIGH); lcd.print("Matteo-Reef"); lcd.setCursor(0,1); lcd.print(""); delay(5000); lcd.clear(); analogWrite(bkl,bklIdle); btnCurrIteration = btnMaxIteration; } /***** Loop *****/ /****************/ void loop() { byte second, minute, hour, dayOfWeek, dayOfMonth, month, year; getDate(&second, &minute, &hour, &dayOfWeek, &dayOfMonth, &month, &year); oldMinCounter = minCounter; minCounter = hour * 60 + minute; //reset plus & minus acceleration counters if the button's state has changed if(plus.stateChanged()) { btnCurrDelay(btnMaxIteration); } if(minus.stateChanged()) { btnCurrDelay(btnMaxIteration); } //check & set fade durations if(oneFadeDuration > onePhotoPeriod/2 && onePhotoPeriod >0){oneFadeDuration = onePhotoPeriod/2;} if(oneFadeDuration<1){oneFadeDuration=1;} if(twoFadeDuration > twoPhotoPeriod/2 && twoPhotoPeriod >0){twoFadeDuration = twoPhotoPeriod/2;} if(twoFadeDuration<1){twoFadeDuration=1;} if(threeFadeDuration > threePhotoPeriod/2 && threePhotoPeriod >0){threeFadeDuration = threePhotoPeriod/2;} if(threeFadeDuration<1){threeFadeDuration=1;} if(fourFadeDuration > fourPhotoPeriod/2 && fourPhotoPeriod > 0){fourFadeDuration = fourPhotoPeriod/2;} if(fourFadeDuration<1){fourFadeDuration=1;} //check & set any time functions //set outputs if(!override){ oneVal = setLed(minCounter, oneLed, oneStartMins, onePhotoPeriod, oneFadeDuration, oneMax, oneInverted); twoVal = setLed(minCounter, twoLed, twoStartMins, twoPhotoPeriod, twoFadeDuration, twoMax, twoInverted); threeVal = setLed(minCounter, threeLed, threeStartMins, threePhotoPeriod, threeFadeDuration, threeMax, threeInverted); fourVal = setLed(minCounter, fourLed, fourStartMins, fourPhotoPeriod, fourFadeDuration, fourMax, fourInverted); } else{ ovrSetAll(overpercent); } //turn the backlight off and reset the menu if the idle time has elapsed if(bklTime + bklDelay < millis() && bklTime > 0 ){ analogWrite(bkl,bklIdle); menuCount = 1; lcd.clear(); bklTime = 0; } //iterate through the menus if(menu.uniquePress()){ analogWrite(bkl,bklOn); bklTime = millis(); if(menuCount < 20){ menuCount++; }else { menuCount = 1; } lcd.clear(); } if(menuCount == 1){ //main screen turn on!!! if (minCounter > oldMinCounter){ lcd.clear(); } lcd.setCursor(0,0); printHMS(hour, minute, second); lcd.setCursor(0,1); lcd.print(oneVal); lcd.setCursor(4,1); lcd.print(twoVal); lcd.setCursor(8,1); lcd.print(threeVal); lcd.setCursor(12,1); lcd.print(fourVal); //debugging function to use the select button to advance the timer by 1 minute //if(select.uniquePress()){setDate(second, minute+1, hour, dayOfWeek, dayOfMonth, month, year);} } if(menuCount == 2){ //Manual Override Menu lcd.setCursor(0,0); lcd.print("Manual Overrides"); lcd.setCursor(0,1); lcd.print("All: "); if(select.uniquePress()){ if(menuSelect < 3){menuSelect++;} else{menuSelect = 0;} bklTime = millis(); } if(menuSelect == 0){ lcd.print("Timer"); override = false;} if(menuSelect == 1){ lcd.print("ON "); overpercent = 100; override = true;} if(menuSelect == 2){ lcd.print("OFF "); overpercent = 0; override = true;} if(menuSelect == 3){ override = true; lcd.print(overpercent,DEC); lcd.print("% "); if(plus.isPressed() && overpercent <100) { overpercent++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && overpercent > 0) { overpercent--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } } if(menuCount == 3){ //set start time for channel one lcd.setCursor(0,0); lcd.print("Channel 1 Start"); lcd.setCursor(0,1); printMins(oneStartMins, true); if(plus.isPressed() && oneStartMins < 1440){ oneStartMins++; if(onePhotoPeriod >0){onePhotoPeriod--;} else{onePhotoPeriod=1439;} delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && oneStartMins > 0){ oneStartMins--; if(onePhotoPeriod<1439){onePhotoPeriod++;} else{onePhotoPeriod=0;} delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 4){ //set end time for channel one lcd.setCursor(0,0); lcd.print("Channel 1 End"); lcd.setCursor(0,1); printMins(oneStartMins+onePhotoPeriod, true); if(plus.isPressed()){ if(onePhotoPeriod < 1439){ onePhotoPeriod++;} else{ onePhotoPeriod=0; } delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed()){ if(onePhotoPeriod >0){ onePhotoPeriod--;} else{ onePhotoPeriod=1439; } delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 5){ //set fade duration for channel one lcd.setCursor(0,0); lcd.print("Channel 1 Fade"); lcd.setCursor(0,1); printMins(oneFadeDuration, false); if(plus.isPressed() && (oneFadeDuration < onePhotoPeriod/2 || oneFadeDuration == 0)){ oneFadeDuration++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && oneFadeDuration > 1){ oneFadeDuration--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 6){ //set intensity for channel one lcd.setCursor(0,0); lcd.print("Channel 1 Max"); lcd.setCursor(1,1); lcd.print(oneMax); lcd.print(" "); if(plus.isPressed() && oneMax < 100){ oneMax++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && oneMax > 0){ oneMax--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 7){ //set start time for channel two lcd.setCursor(0,0); lcd.print("Channel 2 Start"); lcd.setCursor(0,1); printMins(twoStartMins, true); if(plus.isPressed() && twoStartMins < 1440){ twoStartMins++; if(twoPhotoPeriod >0){twoPhotoPeriod--;} else{twoPhotoPeriod=1439;} delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && twoStartMins > 0){ twoStartMins--; if(twoPhotoPeriod<1439){twoPhotoPeriod++;} else{twoPhotoPeriod=0;} delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 8){ //set end time for channel two lcd.setCursor(0,0); lcd.print("Channel 2 End"); lcd.setCursor(0,1); printMins(twoStartMins+twoPhotoPeriod, true); if(plus.isPressed()){ if(twoPhotoPeriod < 1439){ twoPhotoPeriod++;} else{ twoPhotoPeriod=0; } delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed()){ if(twoPhotoPeriod >0){ twoPhotoPeriod--;} else{ twoPhotoPeriod=1439; } delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 9){ //set fade duration for channel two lcd.setCursor(0,0); lcd.print("Channel 2 Fade"); lcd.setCursor(0,1); printMins(twoFadeDuration, false); if(plus.isPressed() && (twoFadeDuration < twoPhotoPeriod/2 || twoFadeDuration == 0)){ twoFadeDuration++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && twoFadeDuration > 1){ twoFadeDuration--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 10){ //set intensity for channel two lcd.setCursor(0,0); lcd.print("Channel 2 Max"); lcd.setCursor(1,1); lcd.print(twoMax); lcd.print(" "); if(plus.isPressed() && twoMax < 100){ twoMax++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && twoMax > 0){ twoMax--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 11){ //set start time for channel three lcd.setCursor(0,0); lcd.print("Channel 3 Start"); lcd.setCursor(0,1); printMins(threeStartMins, true); if(plus.isPressed() && threeStartMins < 1440){ threeStartMins++; if(threePhotoPeriod >0){threePhotoPeriod--;} else{threePhotoPeriod=1439;} delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && threeStartMins > 0){ threeStartMins--; if(threePhotoPeriod<1439){threePhotoPeriod++;} else{threePhotoPeriod=0;} delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 12){ //set end time for channel three lcd.setCursor(0,0); lcd.print("Channel 3 End"); lcd.setCursor(0,1); printMins(threeStartMins+threePhotoPeriod, true); if(plus.isPressed()){ if(threePhotoPeriod < 1439){ threePhotoPeriod++;} else{ threePhotoPeriod=0; } delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed()){ if(threePhotoPeriod >0){ threePhotoPeriod--;} else{ threePhotoPeriod=1439; } delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 13){ //set fade duration for channel three lcd.setCursor(0,0); lcd.print("Channel 3 Fade"); lcd.setCursor(0,1); printMins(threeFadeDuration, false); if(plus.isPressed() && (threeFadeDuration < threePhotoPeriod/2 || threeFadeDuration == 0)){ threeFadeDuration++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && threeFadeDuration > 1){ threeFadeDuration--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 14){ //set intensity for channel three lcd.setCursor(0,0); lcd.print("Channel 3 Max"); lcd.setCursor(1,1); lcd.print(threeMax); lcd.print(" "); if(plus.isPressed() && threeMax < 100){ threeMax++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && threeMax > 0){ threeMax--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 15){ //set start time for channel four lcd.setCursor(0,0); lcd.print("Channel 4 Start"); lcd.setCursor(0,1); printMins(fourStartMins, true); if(plus.isPressed() && fourStartMins < 1440){ fourStartMins++; if(fourPhotoPeriod >0){fourPhotoPeriod--;} else{fourPhotoPeriod=1439;} delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && fourStartMins > 0){ fourStartMins--; if(fourPhotoPeriod<1439){fourPhotoPeriod++;} else{fourPhotoPeriod=0;} delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 16){ //set end time for channel four lcd.setCursor(0,0); lcd.print("Channel 4 End"); lcd.setCursor(0,1); printMins(fourStartMins+fourPhotoPeriod, true); if(plus.isPressed()){ if(fourPhotoPeriod < 1439){ fourPhotoPeriod++;} else{ fourPhotoPeriod=0; } delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed()){ if(fourPhotoPeriod >0){ fourPhotoPeriod--;} else{ fourPhotoPeriod=1439; } delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 17){ //set fade duration for channel four lcd.setCursor(0,0); lcd.print("Channel 4 Fade"); lcd.setCursor(0,1); printMins(fourFadeDuration, false); if(plus.isPressed() && (fourFadeDuration < fourPhotoPeriod/2 || fourFadeDuration == 0)){ fourFadeDuration++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && fourFadeDuration > 1){ fourFadeDuration--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 18){ //set intensity for channel four lcd.setCursor(0,0); lcd.print("Channel 4 Max"); lcd.setCursor(1,1); lcd.print(fourMax); lcd.print(" "); if(plus.isPressed() && fourMax < 100){ fourMax++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && fourMax > 0){ fourMax--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } } if(menuCount == 19){ //set hours lcd.setCursor(0,0); lcd.print("Set Time: Hrs"); lcd.setCursor(0,1); printHMS(hour, minute, second); if(plus.isPressed() && hour < 23){ hour++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && hour > 0){ hour--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } setDate(second, minute, hour, dayOfWeek, dayOfMonth, month, year); } if(menuCount == 20){ //set minutes lcd.setCursor(0,0); lcd.print("Set Time: Mins"); lcd.setCursor(0,1); printHMS(hour, minute, second); if(plus.isPressed() && minute < 59){ minute++; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } if(minus.isPressed() && minute > 0){ minute--; delay(btnCurrDelay(btnCurrIteration-1)); bklTime = millis(); } setDate(second, minute, hour, dayOfWeek, dayOfMonth, month, year); } } |
up
|
up, qualcuno mi aiuta?
|
c'e qualche cristiano che può aiutarmi? :((
|
improbabile marco, non sono in molti a scrivere codice per arduino sul forum che andrebbe poi anche testato.
io stesso ho arduino ma sono alle "prime armi", per ora ho fatto questo con valori random dato che per ora non ho ancora la vasca, ma cmq cambia poco, leggere da un sonda l'ho già testato. se e quando saremo di più proveremo magari ad aprire una sezione nel forum dedicata. http://s24.postimg.cc/4vrfd0hj9/image.png |
qualcuno c'e aveva pure scritto nel post poi sparito
|
Marco se stai parlando di me t'ho anche risposto in MP dandoti i motivi del ritardo. Appena ho un attimo ci guardo. [emoji2]
Però vorrei spiegarti che programmare non è una cosa così semplice e veloce, quindi c'è chi non vuole "regalare" il proprio tempo, c'è chi non è sicuro e preferisce restarne fuori e c'è chi dedica per passione tempo alla programmazione ritagliando il tempo per farlo alla famiglia e a tutti gli altri impegni che ognuno di noi ha. Io t'ho dato la mia disponibilità vincolata purtroppo al tempo che ho, se questo non bastasse perchè hai bisogno subito ti chiedo scusa per averti rubato tempo. |
Grz mille tranquillo aspetto
|
Ciao marco, scrivo solo per rassicurarti, non mi son scordato.
strutturare il menù per 8accensioni separate m'ha dato più problemi del previsto ma ora dovrei aver risolto. t'ho preparato già la gestione della temperatura (che visto che non avevo capito se ti serviva per raffreddare o scaldare te le ho implementate entrambe). ora mi rimane solo da sincronizzare gli orari e le rampe dell'alba tramonto e dovrei essere a posto. |
Ti ringrazio molto non so come sdebitarmi
|
Vi seguo interessato
|
@marco3020
ti chiedo scusa per il ritardo ma ci sono quasi.
Purtroppo il tempo latita causa lavoro ma ci sto lavorando, quando vedrai il codice capirai la causa del ritardo.... |
Tranquillo ti ringrazio ancora per il tuo aiuto
|
Finalmente è finito
Ciao
@marco3020
, ciao
@Colaki
e ciao a tutti quelli che vorranno seguire questa discussione.
Come promesso a Marco ho realizzato il codice da lui richiesto che prevedeva: - accensione di 8 canali separati ed indipendenti di led - alba e tramonto per ogni canale - gestione temperatura (riscaldatore e refrigeratore) Hardware: - Arduino Mega 2560 rev.3 - RTC DS1307 - Display LCD 1602 - 6 pulsanti da circuito stampato (sto implementando il settimo per la navigazione del menù --> movimento back) - 6 resistenze di pulldown (10 KΏ) - sensore di temperatura - resistenza variabile (se volete poter regolare la luminosità del vostro LCD) La cosa, secondo me, più difficile in questa progettazione è stata l'assoluta indipendenza di ogni canale e la possibilità di regolare in maniera diversa ognuno di questi (per ogni canale si può decidere l'orario dell'inizio alba, la durata, l'inizio del tramonto e la durata di quest'ultimo). Quindi se si volesse far accendere prima il sesto canale e poi il primo basterebbe impostarlo così nei relativi campi #70. La gestione del menù ha portato via molto tempo (ci sono più di 100 variabili a definire solo le regolazioni dei canali tra orari durate ecc. oltre alle variabili "di sistema" per gli orari le temperature ed altre cosine. La temperatura viene rilevata una volta al secondo. Dopo la misurazione questo dato viene passato ad un ciclo di controllo che verifica se la temperatura rientra nei delta impostati, sia per la refrigerazione che per il riscaldamento, rispetto alle temperature di riferimento (a loro volta impostabili da menù. Durante le prove fatte sulla protoboard, ho notato che se il sensore viene installato troppo vicino ad altri componenti elettronici, risente molto dei campi magnetici emessi, sballando ( a volte anche di 5 - 6°) la temperatura rilevata. Iniziamo il lavoro vero e proprio modificando la libreria menuBackend.h aggiungere, alla riga 195 del file MenuBackend.h subito prima della riga con scritto "private:", questo metodo: codice:
void toRoot() { Ora qualche foto del progetto di prototipazione (vi prego scusate il casino di fili ma durante lo sviluppo ho aggiunto, tolto, spostato e rispostato...risultato....?) http://s29.postimg.cc/kecqo9qn7/IMG_20140813_162938.jpg http://s8.postimg.cc/ga31t8ixd/IMG_20140813_162950.jpg http://s13.postimg.cc/adgogl2dv/IMG_20140813_163003.jpg http://s1.postimg.cc/dxepyal2j/IMG_20140813_163018.jpg a questo punto credo che non manchi più niente...apparte lo il codice #28g codice:
Ma per qualsiasi domanda o dubbio non esitate a chiedere. Spero che vi piaccia....e soprattutto che funzioni!!#rotfl# Ciao Alla prossima!! |
1 allegato(i)
Purtroppo ho dovuto "tagliare" in due il codice perché troppo lungo per essere pubblicato intero.
Quello che segue è solo il completamento del codice precedente. codice:
#28 stay tunned Gaetano EDIT: in allegato la libreria modificata. Basta inserirla nella cartella Programmi>Arduino>Libreries>Cartella_a_scelta rinominandolo MenuBackend.h e riavviare Arduino |
...cosa dire...leggendo mi trovo in affanno per ....questo sketch. Pensa solo oggi son riuscito a capire come cambiare/inserire l'ora al ds1307.
Tanto di cappello. Sono basito. I mie complimenti. Mi sa ..se lo vorrai...che ti disturberò... Ancora bravo!!!!!!!!!! |
Quote:
Ho disegnato anche l'assemblaggio dei componenti http://s27.postimg.cc/5irpirenj/arduino_marco_bb.jpg |
Ragazzi scusate ho trovato un errore nel void loop()
Ho corretto la seconda parte di sketch pubblicata nel post precedente. Per chi avesse già caricato lo sketch nell'ide: - alla riga 625 correggere codice:
alba3=true; codice:
alba5=true; |
Ciao, al rientro a casa ho voluto provare il tuo sketch, copiato ed inserito, alla verifica mi evidenzia la riga 1673
if(newMenuItem.getName()==menu.getRoot()){ con questo errore no match for 'operator==' in 'newMenuItem.MenuItem::getName()==menu.MenuBackend ::getRoot()' è errata la mia libreria MenuBackend?? Solo per curiosità |
Cavolo
@Colaki
grazie per la segnalazione!
mi ero dimenticato di dirvi che bisogna anche modificare la libreria menuBackend.h aggiungere, alla riga 195 del file MenuBackend.h subito prima della riga con scritto "private:", questo metodo: codice:
void toRoot() { |
Ok questa sera provo e ti faccio sapere!#70
|
Ragazzi io sono in vacanza non ho ancora provato uff
|
Quote:
Poi pensa a quante fatiche ti stai risparmiando... @Colaki ti sta facendo da beta tester!!#rotfl# |
Aggiornato il post 23 aggiungendo l'allegato della libreria modificata.
|
eccomi ho provato lo sketch mi da questo errore :(
<a target="_blank" href="http://imageshack.com/f/iqRogOdPp"><img src="http://imagizer.imageshack.us/v2/150x100q90/674/RogOdP.png" border="0"></a> |
Quote:
|
No credo che abbia solo incollato male lo screenshot dell'errore.
@marco3020
non si vede l'inmagine
|
Buongiorno a tutti ho riprovato facendo il copia e incolla dal post ma mi da sempre stesso errore :(
http://s30.postimg.cc/rlz72sh9p/copi...SSO_ERRORE.jpg |
Ciao
@marco3020
, potresti copia/incollarmi tutto il messaggio di errore che ti da? Mi servono soprattutto le prime righe di quel messaggio.
|
ecco:
sketch_sep09a:17: error: variable or field 'setMode' declared void sketch_sep09a:17: error: 'DateTime' was not declared in this scope sketch_sep09a:18: error: variable or field 'menuChanged' declared void sketch_sep09a:18: error: 'MenuChangeEvent' was not declared in this scope sketch_sep09a:19: error: variable or field 'menuUsed' declared void sketch_sep09a:19: error: 'MenuUseEvent' was not declared in this scope sketch_sep09a:21: error: 'RTC_DS1307' does not name a type sketch_sep09a:222: error: 'MenuBackend' does not name a type sketch_sep09a:226: error: 'MenuItem' does not name a type sketch_sep09a:227: error: 'MenuItem' does not name a type sketch_sep09a:228: error: 'MenuItem' does not name a type sketch_sep09a:229: error: 'MenuItem' does not name a type sketch_sep09a:230: error: 'MenuItem' does not name a type sketch_sep09a:231: error: 'MenuItem' does not name a type sketch_sep09a:232: error: 'MenuItem' does not name a type sketch_sep09a:233: error: 'MenuItem' does not name a type sketch_sep09a:234: error: 'MenuItem' does not name a type sketch_sep09a:235: error: 'MenuItem' does not name a type sketch_sep09a:236: error: 'MenuItem' does not name a type sketch_sep09a:237: error: 'MenuItem' does not name a type sketch_sep09a:238: error: 'MenuItem' does not name a type sketch_sep09a:239: error: 'MenuItem' does not name a type sketch_sep09a:240: error: 'MenuItem' does not name a type sketch_sep09a:241: error: 'MenuItem' does not name a type sketch_sep09a:242: error: 'MenuItem' does not name a type sketch_sep09a:243: error: 'MenuItem' does not name a type sketch_sep09a:244: error: 'MenuItem' does not name a type sketch_sep09a:245: error: 'MenuItem' does not name a type sketch_sep09a:246: error: 'MenuItem' does not name a type sketch_sep09a:247: error: 'MenuItem' does not name a type sketch_sep09a:248: error: 'MenuItem' does not name a type sketch_sep09a:249: error: 'MenuItem' does not name a type sketch_sep09a:250: error: 'MenuItem' does not name a type sketch_sep09a:251: error: 'MenuItem' does not name a type sketch_sep09a:252: error: 'MenuItem' does not name a type sketch_sep09a:253: error: 'MenuItem' does not name a type sketch_sep09a:254: error: 'MenuItem' does not name a type sketch_sep09a:255: error: 'MenuItem' does not name a type sketch_sep09a:256: error: 'MenuItem' does not name a type sketch_sep09a:257: error: 'MenuItem' does not name a type sketch_sep09a:258: error: 'MenuItem' does not name a type sketch_sep09a:259: error: 'MenuItem' does not name a type sketch_sep09a:260: error: 'MenuItem' does not name a type sketch_sep09a:261: error: 'MenuItem' does not name a type sketch_sep09a:262: error: 'MenuItem' does not name a type sketch_sep09a:263: error: 'MenuItem' does not name a type sketch_sep09a:264: error: 'MenuItem' does not name a type sketch_sep09a:265: error: 'MenuItem' does not name a type sketch_sep09a:266: error: 'MenuItem' does not name a type sketch_sep09a:270: error: 'MenuItem' does not name a type sketch_sep09a:271: error: 'MenuItem' does not name a type sketch_sep09a:272: error: 'MenuItem' does not name a type sketch_sep09a:273: error: 'MenuItem' does not name a type sketch_sep09a:274: error: 'MenuItem' does not name a type sketch_sep09a:275: error: 'MenuItem' does not name a type sketch_sep09a:276: error: 'MenuItem' does not name a type sketch_sep09a:279: error: 'MenuItem' does not name a type sketch_sep09a:280: error: 'MenuItem' does not name a type sketch_sep09a.ino: In function 'void setup()': sketch_sep09a:319: error: 'RTC' was not declared in this scope sketch_sep09a:324: error: 'DateTime' was not declared in this scope sketch_sep09a:328: error: 'menu' was not declared in this scope sketch_sep09a:328: error: 'menu1Item1' was not declared in this scope sketch_sep09a:328: error: 'menu1Item2' was not declared in this scope sketch_sep09a:328: error: 'menu1Item3' was not declared in this scope sketch_sep09a:329: error: 'menuCanale1' was not declared in this scope sketch_sep09a:329: error: 'menuCanale2' was not declared in this scope sketch_sep09a:329: error: 'menuCanale3' was not declared in this scope sketch_sep09a:329: error: 'menuCanale4' was not declared in this scope sketch_sep09a:329: error: 'menuCanale5' was not declared in this scope sketch_sep09a:329: error: 'menuCanale6' was not declared in this scope sketch_sep09a:329: error: 'menuCanale7' was not declared in this scope sketch_sep09a:329: error: 'menuCanale8' was not declared in this scope sketch_sep09a:330: error: 'menuCanale1ACH1' was not declared in this scope sketch_sep09a:330: error: 'menuCanale1FACH1' was not declared in this scope sketch_sep09a:330: error: 'menuCanale1TCH1' was not declared in this scope sketch_sep09a:330: error: 'menuCanale1FTCH1' was not declared in this scope sketch_sep09a:331: error: 'menuCanale2ACH1' was not declared in this scope sketch_sep09a:331: error: 'menuCanale2FACH1' was not declared in this scope sketch_sep09a:331: error: 'menuCanale2TCH1' was not declared in this scope sketch_sep09a:331: error: 'menuCanale2FTCH1' was not declared in this scope sketch_sep09a:332: error: 'menuCanale3ACH1' was not declared in this scope sketch_sep09a:332: error: 'menuCanale3FACH1' was not declared in this scope sketch_sep09a:332: error: 'menuCanale3TCH1' was not declared in this scope sketch_sep09a:332: error: 'menuCanale3FTCH1' was not declared in this scope sketch_sep09a:333: error: 'menuCanale4ACH1' was not declared in this scope sketch_sep09a:333: error: 'menuCanale4FACH1' was not declared in this scope sketch_sep09a:333: error: 'menuCanale4TCH1' was not declared in this scope sketch_sep09a:333: error: 'menuCanale4FTCH1' was not declared in this scope sketch_sep09a:334: error: 'menuCanale5ACH1' was not declared in this scope sketch_sep09a:334: error: 'menuCanale5FACH1' was not declared in this scope sketch_sep09a:334: error: 'menuCanale5TCH1' was not declared in this scope sketch_sep09a:334: error: 'menuCanale5FTCH1' was not declared in this scope sketch_sep09a:335: error: 'menuCanale6ACH1' was not declared in this scope sketch_sep09a:335: error: 'menuCanale6FACH1' was not declared in this scope sketch_sep09a:335: error: 'menuCanale6TCH1' was not declared in this scope sketch_sep09a:335: error: 'menuCanale6FTCH1' was not declared in this scope sketch_sep09a:336: error: 'menuCanale7ACH1' was not declared in this scope sketch_sep09a:336: error: 'menuCanale7FACH1' was not declared in this scope sketch_sep09a:336: error: 'menuCanale7TCH1' was not declared in this scope sketch_sep09a:336: error: 'menuCanale7FTCH1' was not declared in this scope sketch_sep09a:337: error: 'menuCanale8ACH1' was not declared in this scope sketch_sep09a:337: error: 'menuCanale8FACH1' was not declared in this scope sketch_sep09a:337: error: 'menuCanale8TCH1' was not declared in this scope sketch_sep09a:337: error: 'menuCanale8FTCH1' was not declared in this scope sketch_sep09a:338: error: 'menuRiscaldatore' was not declared in this scope sketch_sep09a:338: error: 'menuRefrigeratore' was not declared in this scope sketch_sep09a:339: error: 'menuTempRisc' was not declared in this scope sketch_sep09a:339: error: 'menuDeltaRisc' was not declared in this scope sketch_sep09a:340: error: 'menuTempRefrig' was not declared in this scope sketch_sep09a:340: error: 'menuDeltaRefrig' was not declared in this scope sketch_sep09a:341: error: 'menuData' was not declared in this scope sketch_sep09a.ino: In function 'void pulischermo()': sketch_sep09a:361: error: 'DateTime' was not declared in this scope sketch_sep09a:361: error: expected `;' before 'now' sketch_sep09a:362: error: 'now' was not declared in this scope sketch_sep09a.ino: In function 'void loop()': sketch_sep09a:421: error: 'DateTime' was not declared in this scope sketch_sep09a:421: error: expected `;' before 'now' sketch_sep09a:439: error: 'now' was not declared in this scope sketch_sep09a:443: error: 'now' was not declared in this scope sketch_sep09a:446: error: 'now' was not declared in this scope sketch_sep09a:450: error: 'now' was not declared in this scope sketch_sep09a:453: error: 'now' was not declared in this scope sketch_sep09a:457: error: 'now' was not declared in this scope sketch_sep09a:460: error: 'now' was not declared in this scope sketch_sep09a:464: error: 'now' was not declared in this scope sketch_sep09a:467: error: 'now' was not declared in this scope sketch_sep09a:471: error: 'now' was not declared in this scope sketch_sep09a:474: error: 'now' was not declared in this scope sketch_sep09a:478: error: 'now' was not declared in this scope sketch_sep09a:481: error: 'now' was not declared in this scope sketch_sep09a:485: error: 'now' was not declared in this scope sketch_sep09a:488: error: 'now' was not declared in this scope sketch_sep09a:492: error: 'now' was not declared in this scope sketch_sep09a:496: error: 'now' was not declared in this scope sketch_sep09a:510: error: 'now' was not declared in this scope sketch_sep09a:524: error: 'now' was not declared in this scope sketch_sep09a:538: error: 'now' was not declared in this scope sketch_sep09a:551: error: 'now' was not declared in this scope sketch_sep09a:565: error: 'now' was not declared in this scope sketch_sep09a:578: error: 'now' was not declared in this scope sketch_sep09a:592: error: 'now' was not declared in this scope sketch_sep09a:605: error: 'now' was not declared in this scope sketch_sep09a:619: error: 'now' was not declared in this scope sketch_sep09a:632: error: 'now' was not declared in this scope sketch_sep09a:646: error: 'now' was not declared in this scope sketch_sep09a:659: error: 'now' was not declared in this scope sketch_sep09a:673: error: 'now' was not declared in this scope sketch_sep09a:686: error: 'now' was not declared in this scope sketch_sep09a:700: error: 'now' was not declared in this scope sketch_sep09a:726: error: 'now' was not declared in this scope sketch_sep09a:742: error: 'setMode' was not declared in this scope sketch_sep09a:1530: error: 'setMode' was not declared in this scope sketch_sep09a.ino: At global scope: sketch_sep09a:1556: error: variable or field 'setMode' declared void sketch_sep09a:1556: error: 'DateTime' was not declared in this scope |
allora la maggior parte degli errori mi sembrano legati alla libreria menuBachend. Hai modificato il file o hai caricato quello allegato al post?
|
il file menubackend l'ho messo in programmi/ arduino/ libraries/ liquid cristal,
e poi ho fatto copia e incolla del tuo sketch., ( per il sensore di temperatura per la plafo quale consigli) |
Tutti gli orari sono GMT +2. Attualmente sono le 11:42. |
Powered by vBulletin versione 3.8.9
Copyright ©: 2000 - 2024, Jelsoft Enterprises Ltd.
Traduzione italiana Team: AcquaPortal
User Alert System provided by
Advanced User Tagging v3.2.5 Patch Level 2 (Lite) -
vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Copyright Zero Pixel Srl