How to Make a Water Level Alarm With Nano Board



About: We're an ambitious team for developing STEM education by Arduino and Raspberry Pi learning kits as well as robots and aircraft models/drones. Happy to bring you more fun projects and works. Welcome to visit ...

Nowadays water tank has been widely used to store water for department. But there is one problem, how can we know there is no water or the bumping water overflows in time? It’s real inconvenient to check the state again and again. With some programming knowledge, I decide make this alarm to inform with beeping and light indicator. This can be applied to some water level invisible tank or tower.

Have a try!

Step 1: Prepare Materials

SunFounder Nano board -

USB cable

Some jumper wires -

4 LEDs (white, green, yellow, red)

Passive buzzer

Plastic bottle

Foam board

Drinking straw

Dielectric stick


Electrical Tape

Color Pen

Step 2: Make a Water Tank

Stab at the bottom of the bottle to get a hole, then thread the drinking stick across the hole, and seal with glue.

Step 3: Make Water Level Probe

Fasten a jumper wire’s one end to the bottom of the stick and the other end to +5V power. Fasten the four other wires evenly on the stick in the same way. (Adjust the interval distance according to your actual needs)

Step 4: Insert the LEDs and Buzzer

Draw a whale (whatever other image you like) on a paper and paint with color, then paste this paper on the foam board. Insert the buzzer to the whale’s eye position, and four LED to the spout position in order. (Insert those components’ pins across the foam board, thus the wiring in later part will be easier.)

Step 5: Wiring

Complete the wiring as shown:

Step 6: Upload the Code

#define uchar unsigned char
uchar flag = 4;
void setup()
  Serial.begin(9600);  // start serial port at 9600 bps:
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
void loop()
  int w = analogRead(A0); //read the value from analog pin AO
  int g = analogRead(A1);
  int y = analogRead(A2); 
  int r = analogRead(A3);
  if((w< 1000) && (g > 1000) && (y > 1000) && (r > 1000))                      //Stop when the car is picked up
   flag = 0; 
    else if ((w< 1000) && (g < 1000) && (y > 1000) && (r > 1000))                            //if read the value of the Tracking module data[0] is more than 100
    flag = 1;        
      else if((w< 1000) && (g < 1000) && (y < 1000) && (r > 1000))                              //if read the value of the Tracking module data[2] is more than 100
      flag = 2; 
        else if((w< 1000) && (g < 1000) && (y > 1000) && r< 1000)                           //if read the value of the Tracking module data[4] is more than 100
        flag = 3; 
        flag = 4;
  switch(flag)   //According to the relative position of the line and the car, adjust the front wheel steering angle to change the direction of the car to achieve inspection line.
    case 0:
    digitalWrite(3, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    case 1: 
    digitalWrite(2, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW);
    case 2: 
    digitalWrite(4,HIGH);//turn the LED on
    digitalWrite(2, LOW);
    digitalWrite(3, LOW);
    digitalWrite(5, LOW);
    pinMode(9, OUTPUT); //set the pin 9 as an output
    tone(9, 3000, 100);
    tone(9, 0, 10);
    pinMode(9, INPUT); //set the pin 9 as an input
    case 3: 
      digitalWrite(2, LOW);
      digitalWrite(4, LOW);
      digitalWrite(3, LOW);
      pinMode(9, OUTPUT);
    tone(9, 3000, 100);
    tone(9, 0, 10);
    pinMode(9, INPUT); 
    case 4: 
    digitalWrite(3, LOW);
    digitalWrite(2, LOW);
    digitalWrite(4, LOW);
    digitalWrite(5, LOW); 

Step 7: Put the Stick in Water Tank

Step 8: Water Level Indicator Done!

Clog the drinking straw on the tank, and add water to the tank until the water reaches the topmost probe.

Release the clogging, then observe the water level and the LED.



    • Paper Contest

      Paper Contest
    • Weaving Challenge

      Weaving Challenge
    • Epilog X Contest

      Epilog X Contest