azz, in 2 ore il topic e' andato a in seconda pagina! scrivo per riportarlo in alto visto che e' utilissimo.
allora ho fatto il codice della mia mangiatoia per pesci usando l' swrtc di leo, ora son segnati 9 allarmi che corrispondono a 9 pasti giornalieri
problema: vorrei poter decidere quanti pasti distribuire, ho un rotary switch binario da 0 a 9 collegato su A1-2-3-4 come posso integrare questo tipo di selezione nel codice? ovvero 1 pasto/giorno 2pasti/giorno ... 9 pasti/giorno mi serve uno spunto, non so come fare...
#include <swRTC.h>
swRTC rtc;
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
const int motordx = 9;
const int motorsx = 8;
const int finecorsadx = 7;
const int finecorsasx = 6;
const int bit1 = A1;
const int bit2 = A2;
const int bit3 = A3;
const int bit4 = A4;
int avvio = 0;
int valavvio = 0;
int valfinecorsadx = 0;
int valfinecorsasx = 0;
void setup() {
delay(2000);
rtc.stopRTC();
rtc.setTime(20,00,30);
rtc.startRTC();
lcd.begin(16, 2);
pinMode(motordx, OUTPUT);
pinMode(motorsx, OUTPUT);
pinMode(finecorsadx, INPUT);
pinMode(finecorsasx, INPUT);
}
void loop() {
lcd.setCursor(5, 0);
lcd.print(rtc.getHours(), DEC);
lcd.print(":");
lcd.print(rtc.getMinutes(), DEC);
lcd.print(":");
lcd.print(rtc.getSeconds(), DEC);
lcd.print(" ");
if ((6==rtc.getHours()) && (30==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
if ((8==rtc.getHours()) && (0==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
if ((9==rtc.getHours()) && (30==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
if ((11==rtc.getHours()) && (0==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
if ((12==rtc.getHours()) && (30==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
if ((14==rtc.getHours()) && (0==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
if ((15==rtc.getHours()) && (30==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
if ((17==rtc.getHours()) && (0==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
if ((18==rtc.getHours()) && (30==rtc.getMinutes()) && (0==rtc.getSeconds())) {
(avvio = 1);
}
valavvio = avvio;
if (valavvio == 1){
avvio = 0;
digitalWrite(motordx, HIGH);
}
valfinecorsadx = digitalRead(finecorsadx);
if (valfinecorsadx == HIGH){
digitalWrite(motordx, LOW);
delay(50);
digitalWrite(motorsx, HIGH);
}
valfinecorsasx = digitalRead(finecorsasx);
if (valfinecorsasx == HIGH){
digitalWrite(motorsx, LOW);
}
}