Lesson 18--Microduino "Make a flood water level alarm model"

来自Microduino Wikipedia
跳转至: 导航搜索
Language English

Objective

This 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

  • Microduino-Core
  • Microduino-FT232R
  • Other hardware equipment
    • Breadboard Jumper one box
    • Breadboard one piece
    • LED one
    • 10k,220Ω resistor one
    • USB Data cable one
    • Active buzzer one

Experimental schematic

Note:use active buzzer in this experiment, it can make a sound under a voltage.

Lesson18-schematic.jpg

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.

Program

void 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.

Result

After 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