'mySwitch' was not declared in this scope

i am new to programming I am retired I am working on level indicators for my boat. I have read different responses to this problem but I don’t understand the answers. Please show me what I am missing. Below is the code I am trying to compile:

Thank you in advance, Everett

sketch_mar12d.ino (1.47 KB)

Please show your code.
In code tags.

Hello
Welcome to the Arduino fora.
Before you do anything else please take a moment to read General guidance
And How to use this forum
Especially item #7 on posting code.
Thank you.

The OP’s code:

#include <LiquidCrystal.h>

#define trigPin 8
#define echoPin 9
#define trigPin2 6
#define echoPin2 7
#include <liquidcrystal.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup(){
	int duration,distance,percentage,heightTank;
	Serial.begin (9600);
	pinMode(trigPin,OUTPUT);
	pinMode(echoPin,INPUT);
	lcd.begin(16,2);
	lcd.print("HELLO");
}

void loop(){
	int duration,distance,percentage,percentage2,heightTank,deviation,heightTank2,deviation2;
	//You'll probably want to change the next 2 lines.
	// The first one is the max. level of the water.
	// The next one is how high the sensor is above that max. level.
	heightTank=151;
	deviation=29;
	heightTank2=151;
	deviation2=29;

	digitalWrite(trigPin,HIGH);
	delayMicroseconds(1000);
	digitalWrite(trigPin,LOW);
	duration=pulseIn(echoPin,HIGH);
	distance=(duration/2)/29.1;
	percentage=100-(((distance-deviation)*100)/heightTank);
	Serial.println(distance);
	Serial.println(percentage);
	delay(1000);
	digitalWrite(trigPin2,HIGH);
	delayMicroseconds(1000);
	digitalWrite(trigPin2,LOW);
	duration=pulseIn(echoPin2,HIGH);
	distance=(duration/2)/29.1;
	percentage2=100-(((distance-deviation2)*100)/heightTank2);
	Serial.println(distance);
	Serial.println(percentage2);
	lcd.clear();
	lcd.setCursor(0,0);
	lcd.print("Port Tank ");
	lcd.print(percentage );
	lcd.print(" %");
	mySwitch.resetAvailable();
	lcd.setCursor(0,1);
	lcd.print("Stbd Tank ");
	lcd.print(percentage2);
	lcd.print(" %");
	mySwitch.resetAvailable();
	delay(1000);
}

It seems that the 2 lines

mySwitch.resetAvailable();

come out of nowhere. They are from the library rc-switch, which is not declared. So the code is not complete.
There should be at least

#include <RCSwitch.h>
RCSwitch mySwitch = RCSwitch();

before setup and some related functions in the setup and the loop.

Or just remove those lines if they are not necessary

Here’s a problem:

#include <liquidcrystal.h>

Why are these declared in setup()?

int duration,distance,percentage,heightTank;

Danois90:
Why are these declared in setup()?

int duration,distance,percentage,heightTank;

Don’t worry - there’s a spare set in loop()