rana mohammadi
Published © CERN-OHL

Water height detection sensor

This sensor detects the water level and the module beeps when it reaches the specified range.

BeginnerProtip10 hours141
Water height detection sensor

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1

Software apps and online services

Arduino IDE
Arduino IDE
Visual Studio 2017
Microsoft Visual Studio 2017

Story

Read more

Schematics

Determining the height of the water level

Code

Determining the height of the water level

Arduino
const int sensorPin = A0; // پین آنالوگ متصل به سنسور
   int sensorValue = 0; // متغیر برای ذخیره مقدار سنسور

   void setup() {
       Serial.begin(9600); // راه‌اندازی ارتباط سریال
   }

   void loop() {
       sensorValue = analogRead(sensorPin); // خواندن مقدار سنسور
       float voltage = sensorValue * (5.0 / 1023.0); // تبدیل مقدار به ولتاژ
       float height = (voltage / 5.0) * 100; // تبدیل ولتاژ به ارتفاع (بسته به مشخصات سنسور ممکنه تغییر کنه)

       Serial.print("ارتفاع آب: ");
       Serial.print(height);
       Serial.println(" سانتی‌متر");

       delay(1000); // تاخیر 1 ثانیه‌ای
   }

Credits

rana mohammadi
3 projects • 2 followers

Comments