“Lesson 18--Microduino "Make a flood water level alarm model"”的版本间的差异
(未显示同一用户的1个中间版本) | |||
第1行: | 第1行: | ||
− | {{Language| | + | {{Language|第十八课--Microduino_制作讯线水位报警器模型}} |
{| style="width: 800px;" | {| style="width: 800px;" | ||
|- | |- |
2014年3月2日 (日) 15:00的最新版本
Language | English |
---|
ObjectiveThis lesson will teach you do a most simple line level alarm model, if the water level reached the warning level, warning lights flashing, at the same time with a buzzer alarm prompt. Equipment
Experimental schematicNote:use active buzzer in this experiment, it can make a sound under a voltage. Water is a conductor (except purified water), and add a voltage into the water, the use the analoy port to test it. (Call it as a model, because in actual environment will be somewhat complex and we cannot use water as a conductor directly), if detected voltage, that means the leverl of water has come to our setted leverl. Programvoid setup()
{
pinMode(A5,INPUT);
pinMode(12,OUTPUT);
pinMode(113,OUTPUT);
}
void loop()
{
int n=analogRead(A5);
if (n>=1)
{
digitalWrite(12, HIGH);
digitalWrite(13, HIGH); //Use High level voltage to derive the Active buzzer
delay(500);
digitalWrite(12, LOW);
digitalWrite(13, LOW);
delay(500);
}
}
This program we have introduced many time in previous lesson. It just use the analog port to detect the voltage. You can do more interesting things using this principle. ResultAfter downlaod, when two wires contacted with the water and was conducted, analog will read the voltage, you can see led flash and the buzzer sends "di di..."sound the alarm. Video |