Remove comments

This commit is contained in:
Santiago Lo Coco 2022-05-17 08:00:04 -03:00
parent 0ca6bc4169
commit 9ecd17e501
1 changed files with 18 additions and 62 deletions

View File

@ -1,10 +1,3 @@
/*
ASPECTOS PARA VER:
-usar LastDay en EEPROM ADDRESS 2, con el fin de hacer los reinicios por dia,
ya pude hacerlo con lo del volumen, esto es tarea facil.
*/
//Librerias a utilizar
#include <Time.h> #include <Time.h>
#include <TimeAlarms.h> #include <TimeAlarms.h>
#include <DS1307RTC.h> #include <DS1307RTC.h>
@ -15,10 +8,8 @@
#include <EEPROM.h> #include <EEPROM.h>
#include <MsTimer2.h> #include <MsTimer2.h>
RTC_DS1307 rtc; //defino el RTC RTC_DS1307 rtc;
//Definimos variables
int electro_in1 = 12; int electro_in1 = 12;
int electro_in2 = 11; int electro_in2 = 11;
@ -35,25 +26,19 @@ float volumen;
float volumenMaximo = 0.5; float volumenMaximo = 0.5;
bool flag = false; bool flag = false;
int state = HIGH; // estado actual del pin de salida int state = HIGH;
int reading; // lectura actual del input pin int reading;
int previous = LOW; // lectura anterior del input pin int previous = LOW;
int lastDay; int lastDay;
int eeAddress = 0; int eeAddress = 0;
int EE_ADDR2 = 1; int EE_ADDR2 = 1;
void pulseCounter() {
//del caudalimetro
void pulseCounter()
{
pulseCount++; pulseCount++;
} }
//de memoria eeprom
void flash() { void flash() {
if (analogRead(A1) < 920) { if (analogRead(A1) < 920) {
@ -69,15 +54,12 @@ void flash() {
digitalWrite(electro_in1, HIGH); digitalWrite(electro_in1, HIGH);
digitalWrite(electro_in2, HIGH); digitalWrite(electro_in2, HIGH);
EEPROM.put(eeAddress, volumen); // del volumen EEPROM.put(eeAddress, volumen);
//EEPROM.put(EE_ADDR2, lastDay); // del dia //EEPROM.put(EE_ADDR2, lastDay);
} }
} }
void setup() { void setup() {
Serial.begin(9600); Serial.begin(9600);
pinMode(electro_in1, OUTPUT); pinMode(electro_in1, OUTPUT);
@ -86,43 +68,30 @@ void setup() {
digitalWrite(electro_in2, HIGH); digitalWrite(electro_in2, HIGH);
pinMode(sensorPin, INPUT); pinMode(sensorPin, INPUT);
pinMode(pulsadorPin, INPUT); // pulsador entre pin 3 y GND. pinMode(pulsadorPin, INPUT);
pulseCount = 0;
flowRate = 0.0;
oldTime = 0;
pulseCount = 0;
flowRate = 0.0;
oldTime = 0;
attachInterrupt(sensorInterrupt, pulseCounter, FALLING); attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
//del eeprom
EEPROM.get(eeAddress, volumen); EEPROM.get(eeAddress, volumen);
MsTimer2::set(10, flash); //hermoso timer MsTimer2::set(10, flash);
MsTimer2::start(); MsTimer2::start();
Serial.print("Litros iniciales: "); //al final no lo termine utilizando Serial.print("Litros iniciales: ");
Serial.print(volumen); Serial.print(volumen);
pinMode(13, OUTPUT); pinMode(13, OUTPUT);
digitalWrite(13, LOW); digitalWrite(13, LOW);
//del reloj
//EEPROM.get(EE_ADDR, lastDay); //EEPROM.get(EE_ADDR, lastDay);
} }
void loop() { void loop() {
reading = digitalRead(pulsadorPin);
/*
Todavia no pude arreglar el tema del BOUNCE SWITCH, ver esto, la unica posiblidad a considerar
no es usando un timer sino haciendolo de manera fisica.
*/
reading = digitalRead(pulsadorPin); //para hacer que el boton actue como un "switch"
if (reading == HIGH && previous == LOW) { if (reading == HIGH && previous == LOW) {
delay(500); delay(500);
@ -134,37 +103,28 @@ void loop() {
previous = reading; previous = reading;
//caudalimetro
if (volumen < volumenMaximo && state == LOW) if (volumen < volumenMaximo && state == LOW)
if ((millis() - oldTime) > 1000) { // Un contador por segundo, utilizando millis if ((millis() - oldTime) > 1000) {
detachInterrupt(sensorInterrupt); detachInterrupt(sensorInterrupt);
flowRate = (((1000.0) / (millis() - oldTime)) * pulseCount) / calibrationFactor; flowRate = (((1000.0) / (millis() - oldTime)) * pulseCount) / calibrationFactor;
// Llevarlo al total
volumen += flowRate / 60; volumen += flowRate / 60;
// unsigned int frac;
Serial.print (volumen, 3); Serial.print (volumen, 3);
Serial.println (" L"); Serial.println (" L");
// Reseteamos para volver a empezar
pulseCount = 0; pulseCount = 0;
// Habilitamos la interrupción
attachInterrupt(sensorInterrupt, pulseCounter, FALLING); attachInterrupt(sensorInterrupt, pulseCounter, FALLING);
oldTime = millis(); oldTime = millis();
flag = true; //esto me tengo que fijar, porque ahora anda pero no se si es lo mas conveniente. flag = true;
} }
if (volumen >= volumenMaximo ) { if (volumen >= volumenMaximo ) {
flag = false; flag = false;
} }
//encendido o apagado de electrovalvula
if (flag == true && state == LOW) { if (flag == true && state == LOW) {
digitalWrite(electro_in1, LOW); digitalWrite(electro_in1, LOW);
digitalWrite(electro_in2, LOW); digitalWrite(electro_in2, LOW);
@ -175,10 +135,6 @@ void loop() {
digitalWrite(electro_in2, HIGH); digitalWrite(electro_in2, HIGH);
} }
//reloj, reinicio de volumen cada dia
/* /*
DateTime now; DateTime now;
if (now.day() != lastDay) // this happens exactly once a day. if (now.day() != lastDay) // this happens exactly once a day.