当前位置:网站首页>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
边栏推荐
- Record: the solution of MySQL denial of access when CMD starts for the first time
- TYUT太原理工大学2022软工导论考试题型大纲
- The port is occupied because the service is not shut down normally
- 学编程的八大电脑操作,总有一款你不会
- Share a website to improve your Aesthetics
- Answer to "software testing" exercise: Chapter 1
- 用栈实现队列
- A brief introduction to the database of tyut Taiyuan University of technology in previous years
- System design learning (III) design Amazon's sales rank by category feature
- Novatel board oem617d configuration step record
猜你喜欢
Data manipulation language (DML)
系统设计学习(三)Design Amazon‘s sales rank by category feature
阿里云微服务(一)服务注册中心Nacos以及REST Template和Feign Client
Abstract classes and interfaces
抽象类和接口
Wechat applet development experience
TYUT太原理工大学2022数据库大题之数据库操作
E-R graph to relational model of the 2022 database of tyut Taiyuan University of Technology
How to ensure data consistency between MySQL and redis?
121道分布式面试题和答案
随机推荐
用栈实现队列
View UI Plus 发布 1.1.0 版本,支持 SSR、支持 Nuxt、增加 TS 声明文件
Decomposition relation model of the 2022 database of tyut Taiyuan University of Technology
[Topic terminator]
View UI Plus 发布 1.3.1 版本,增强 TypeScript 使用体验
Music playback (toggle & playerprefs)
【话题终结者】
How do architects draw system architecture blueprints?
十分钟彻底掌握缓存击穿、缓存穿透、缓存雪崩
Alibaba cloud microservices (I) service registry Nacos, rest template and feign client
Role movement in the first person perspective
面试必备:聊聊分布式锁的多种实现!
Alibaba cloud microservices (II) distributed service configuration center and Nacos usage scenarios and implementation introduction
(超详细二)onenet数据可视化详解,如何用截取数据流绘图
WSL common commands
[rtklib] preliminary practice of using robust adaptive Kalman filter under RTK
TYUT太原理工大学2022软工导论简答题
121道分布式面试题和答案
异常:IOException:Stream Closed
面渣逆袭:Redis连环五十二问,三万字+八十图详解。