hi everyone who will read this ,as in the tittle it says I'm a complete newbie but everyone has to start somewhere.
now the project that I want to do is as following:
I want to measure and know how much water i still have in an underground basin, and from the moment that the water level is to low that it open an servomotor and shuts down a 230v powersupply.
this is the code that I've constructed but if i run the test I get errors but I don't see the problem (newbie )
//Ultrasonic sensor Pins:
// VCC: +5VDC
// Trig : Trigger (INPUT) - Pin11
// Echo: Echo (OUTPUT) - Pin 12
// GND: GND
int trigPin = 11; // Trigger
int echoPin = 12; // Echo
long duration = 200;
#include <LiquidCrystal.h>
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
// Relay pin is controlled with D8. The active wire is connected to Normally Closed and common
int relay = 8;
volatile byte relayState = LOW;
// PIR Motion Sensor is connected to D2.
int PIRInterrupt = 2;
// Timer Variables
long lastDebounceTime = 0;
long debounceDelay = 10000
void setup() {
// put your setup code here, to run once:
//Serial Port begin
Serial.begin (9600);
//Define inputs and outputs
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
// time to distance
cm = microsecondsToCentimeters(duration);
distances[arraycounter] = cm;
ttldist=0;
for (int i=O;i<10;i++) {
ttldis+=distances*;*
}
avgdist=ttldist/10;
}
lcd.clear();
lcd.setCursor(0,0); // start at character 0 on line
lcd.print ("cm water: ");
lcd.print (maxheight - avgdist);
lcd.setCursor (0,1);
lcd.print ("L water: ");
//note : avgdist in cm , width in M en length in M
int liters = getLiter ((double)(maxheight-avgdist)/100;width, length);
lcd.print(liters);
delay(100);
arraycounter++;
- // Pin for relay module set as output*
- pinMode(relay, OUTPUT);*
- digitalWrite(relay, HIGH);*
- // PIR motion sensor set as an input*
- pinMode(PIRInterrupt, INPUT);*
- // Triggers detectMotion function on rising mode to turn the relay on, if the condition is met*
- attachInterrupt(digitalPinToInterrupt(PIRInterrupt), detectMotion, RISING);*
- // Serial communication for debugging purposes*
- Serial.begin(9600);*
void loop() { - // put your main code here, to run repeatedly:*