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

From Microduino Wiki
Jump to: navigation, search
Language: English  • 中文


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.


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


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.


void setup()

void loop()
  int n=analogRead(A5);
  if (n>=1)
    digitalWrite(12, HIGH);  
    digitalWrite(13, HIGH); //Use High level voltage to derive the Active buzzer
    digitalWrite(12, LOW); 
    digitalWrite(13, LOW);  

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.


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.