Hey everyone there, so recently I've been tasked with this project where I need to check if the floating liquid level sensor works properly or not, and everything that has to do with the Hardware stuff is just fine, and I'm going to insert a picture below of how I have it connected in my Arduino Uno.
Now, apparently there seems to be a problem with my code on Arduino IDE, this is the code:
for some reason the Serial Monitor is stuck on HIGH all the time and the LED is always on, the problem is not with the Float Sensor itself (I'm sure of that), but I couldn't tell what the problem is with the code.
I've tried another code earlier with few changes and it was something like:
int GREEN=13;
int Float=2;
void setup() {
Serial.begin(9600);
pinMode(GREEN,OUTPUT);
pinMode(Float,INPUT_PULLUP);
}
void loop() {
if (digitalRead (Float == HIGH))
{
Serial.println("WATER LEVEL IS HIGH");
digitalWrite(GREEN,HIGH);
}
if (digitalRead (Float == LOW))
{
Serial.println("WATER LEVEL IS LOW");
digitalWrite(GREEN,LOW);
}
}
and this time the Serial Monitor kept switching almost instantly between HIGH and LOW, and the LED is flickering all the time.
this made me futher more sure that the problem is with the code not the Hardware, I tried and switched the Float Liquid Level Sensor, not once but twice, using 3 different ones, and the problem remained the same, I tried switching the cables and using different ones, and it's still there.
if you can think of a way to solve the problem please reply to this asap, would appreciate it if someone could right down the mistakes, oh and yea here is the project:
I mean isn’t it supposed to be low? It’s not sensing anything, but no matter how much I move the sensor up and down with my hand, the answer serial monitor and the led’s reaction never change.
Basically it’s stuck in a loop, and by the way I didn’t measure it with water but with my hand (i lift it up to and down to act as water)
Im aware of that but i have it connected to 4 on my arduino, i just followed the steps of this drawing and changed the pin from 2 to 4, which is why i changed it in the code as well
Would you be around tomorrow? I honestly posted this after trying too much and almost giving up, i posted here thinking i will get an answer in months.
I’m really grateful for you all but i’m not near the laptop and the arduino anymore