programming ( complete newbie)

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 :cold_sweat: )

//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:*

How to use this forum -- please read.
https://forum.arduino.cc/index.php?topic=148996.0

Get that straight, show us code tags.

The forum software has changed part of your code because you did not post in code tags. And the posted code is not complete.

Read the how to use this forum-please read sticky to see how to properly post code.

Post the entire contets of the error message(s) in code tags.

... and maybe it would help if you read the error message ...

You're completely new to programming, but you're messing around with over 200 Volts? Please be careful! :slight_smile:

Ok I will read the first answer on te forum.
I didn’t saw any problem in it to go to the 230v since everything is controlled with 5v and you need an relay to go over to the 230v

I didn't saw any problem in it to go to the 230v since everything is controlled with 5v and you need an relay to go over to the 230v

NickyC,
For the sake of keeping you alive that worries me a lot. If you can't see any problems messing with 230V then you should not be messing with 230V. Only when you know what the problems are and what to do to mitigate them should you go anywhere near mains power.