Lesson 18--Microduino "Make a flood water level alarm model"
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 |