Un RTC le dice a las 6ymedia de la mañana al arduino que revise el tanque de agua. El sensor ultrasonico junto a una valvula solenoide llenan el tanque.
// el sensor tiene que estar a 20cm del agua
//tengo el sensor y el rtc conectados al arduino y puedo sincronizar la hora O medir distancias sin problemas.
//el RTC es el modelo Tiny RTC y el sensor es el modelo US-020
plantea el problema entero,.
Si tienes problemas para programar eso usa un entorno grafico si lo quieres hacer por ti mismo. Por otro lado ejemplos con RTC y ejemplos con tanques de agua hay un monton...
Como hago que el sensor ultrasonico cierre la valvula de solenoide cuadno el agua este a 20cm del ping?
#include <NewPing.h>
int RELAY = 2; // RELAY Pin.
#define TRIGGER_PIN = 4; // Trigger Pin
#define ECHO_PIN = 5; // Echo Pin
int Dist; // The Distance value
#define MAX_DISTANCE 200
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE); // NewPing setup of pins and maximum distance.
void setup() {
pinMode(RELAY, OUTPUT); //To the relay via the transistor
Dist = 20; //The distance in inches. Change this for increasted or dicreasted range.
}
void loop() {
MAX_DISTANCE = sonar.Ranging(CM); // Range is calculated in Centimeters.
if (MAX_DISTANCE < Dist) {
digitalWrite(RELAY, HIGH);
} else if (MAX_DISTANCE > Dist) {
digitalWrite(RELAY, LOW);
delay(2000);
}
}
me da error
sketch_may29a:9: error: expected primary-expression before '=' token
sketch_may29a:9: error: expected unqualified-id before ',' token
sketch_may29a:9: error: expected unqualified-id before '=' token
sketch_may29a:9: error: expected unqualified-id before ',' token
sketch_may29a:9: error: expected unqualified-id before numeric constant
sketch_may29a.ino: In function 'void loop()':
sketch_may29a:18: error: 'class NewPing' has no member named 'Ranging'
sketch_may29a:18: error: 'CM' was not declared in this scope