当前位置:网站首页>Arduino+ water level sensor +led display + buzzer alarm
Arduino+ water level sensor +led display + buzzer alarm
2022-07-06 13:19:00 【Lunan wind】
Experiment preparation :
arduino mega2560(uno、Nano And other models )
led( yellow 、 green 、 red )
resistance x3( This time I choose 680Ω resistance 1/4w Metal film resistance , avoid led When the lamp is burnt out, pay attention to the resistance value is not too small )
Buzzer ( Here I use active high-level trigger )
Water level sensor ( as follows )

water sensor

Wiring ( The latter can be wired according to the provider )
Experimental procedure
#define water_sensorspin A1
#define led_yellow 2
#define led_green 3
#define led_red 4
#define buzzpin 7
float ad_value=0; // Depth analog value
float deepcm=0; // Actual depth
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led_yellow,OUTPUT); // Set pin status
pinMode(led_green,OUTPUT);
pinMode(led_red,OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
ad_value=analogRead(water_sensorspin); //A1 The pin gets the analog value and assigns the variable
Serial.println("Water level monitoring ready");
delay(20);
Serial.println(ad_value); // Print and observe the change of analog value
deepcm=(ad_value/702)*4; // Measured , At the deepest point, the analog value is about 702, Measure the depth 4cm
Serial.print(" At this time, the depth of water is :");
Serial.print(deepcm);
Serial.println("cm");
if(deepcm<1.5) // The water level is lower than 1.5cm when
{
delay(20);
digitalWrite(led_yellow,HIGH);
digitalWrite(led_green,LOW);
digitalWrite(led_red,LOW);
digitalWrite(buzzpin,LOW);
}
else if(deepcm<3)
{
delay(20);
digitalWrite(led_yellow,LOW);
digitalWrite(led_green,HIGH);
digitalWrite(led_red,LOW);
digitalWrite(buzzpin,LOW);
}
else if(deepcm>3)
{
delay(20);
digitalWrite(led_yellow,LOW);
digitalWrite(led_green,LOW);
digitalWrite(led_red,HIGH);
digitalWrite(buzzpin,HIGH);
Serial.println(" The water level is too high , Be careful !");
}
delay(2000); // The delay jam is slightly longer , The serial port refresh is too fast to see
}Experimental phenomena

The water level sensor is inserted into the water ( Note that the maximum depth should not exceed 4cm)

When the depth is shallow


Moderate depth

When the depth is deep

video
The water level led Show
Buzzer alarm
Basics :led Lighten up , Buzzer alarm
Add other displays to the sensor access
边栏推荐
- Music playback (toggle & playerprefs)
- 西安电子科技大学22学年上学期《基础实验》试题及答案
- Shortest Hamilton path (pressure DP)
- TYUT太原理工大学2022软工导论考试题型大纲
- Application architecture of large live broadcast platform
- Conceptual model design of the 2022 database of tyut Taiyuan University of Technology
- 记录:初次cmd启动MySQL拒接访问之解决
- A brief introduction to the database of tyut Taiyuan University of technology in previous years
- 西安电子科技大学22学年上学期《射频电路基础》试题及答案
- Abstract classes and interfaces
猜你喜欢

Application architecture of large live broadcast platform

面渣逆袭:Redis连环五十二问,三万字+八十图详解。

TYUT太原理工大学2022“mao gai”必背

Application architecture of large live broadcast platform

学编程的八大电脑操作,总有一款你不会

What are the advantages of using SQL in Excel VBA

架构师怎样绘制系统架构蓝图?

Role movement in the first person perspective

Inheritance and polymorphism (I)

TYUT太原理工大学2022数据库题库选择题总结
随机推荐
Chromatic judgement bipartite graph
How to ensure data consistency between MySQL and redis?
阿里云微服务(四) Service Mesh综述以及实例Istio
TYUT太原理工大学2022软工导论简答题
Role movement in the first person perspective
[algorithm] sword finger offer2 golang interview question 9: subarray with product less than k
Error: symbol not found
Sharing ideas of on-chip transplantation based on rtklib source code
Inheritance and polymorphism (Part 2)
Application architecture of large live broadcast platform
167. Sum of two numbers II - input ordered array - Double pointers
Counter attack of flour dregs: redis series 52 questions, 30000 words + 80 pictures in detail.
The port is occupied because the service is not shut down normally
Problems and solutions of robust estimation in rtklib single point location spp
View UI plus released version 1.2.0 and added image, skeleton and typography components
Inheritance and polymorphism (I)
Atomic and nonatomic
Record: solution of 404 error of servlet accessing database in dynamic web project
First acquaintance with C language (Part 2)
Novatel board oem617d configuration step record