Project tutorial
Servo Motor and Water Sensor

Servo Motor and Water Sensor © GPL3+

How to realize a servo and water sensor function using simple raw materials.

  • 21 views
  • 0 comments
  • 0 respects

Components and supplies

About this project

Subject

We use “Servo and water sensor” for know when is raining outside or not; when is raining we can use a potenziometer to regulate a “veranda”. When it’s raining outside, a buzzer will start playing a sound (Mario bros song).

Structure

The external structure is made by plywood (6 mm thickness) worked with laser cutIng, embedded and glued. As is the precedent design is pubblished image of external plywod structure. In the right piece there is the hole for the speaker, in the lef part there is a servo motor with the roll part inside the box. On the ceiling there is a potentometer, it need for govern the servo. At the end there is frontal face where there is a “veranda”. All the plywood are designed by AutoCad. Plywood pieces are assembling with vinyl glue it consent to block all the component.

Data Transmission

The water sensor receive datas more remarkable than 250. The servo motor receive signal by potenziometer. Potenziometer trasform values from 0- 1023 to 0- 180.

Electricity Supply

Arduino is powered by a powerbank (9V ). If the speaker use too much volt you may use a resistance.

Variations

It is possible to use one single 5V battery for the alimentaton, but that could exhaust the speaker. It’s possible to use a angle regulator sensor. Also you can use buzzer instead of the speaker. You may use PMMA piece.

Code

codeArduino
#include <Servo.h>

Servo myservo;  
int potpin = A1;  
int val;
const int waterSens = A0; //define water sensor to pin A0
const int buzzer = 8; //define speaker to pin 8
int SensorValue; //create sensor data variable

void setup() 
{
  pinMode(buzzer, OUTPUT);//set speaker as an output
  pinMode(waterSens, INPUT); //set water sensor as an input   
  myservo.attach(9);          
}

void loop() 
{
  
  int sensorValue = analogRead(waterSens);//read the water sensor value

if (sensorValue <= 250) 
{     
    tone(buzzer, 660 ,100);  
delay ( 150);  
tone(buzzer, 660 ,100);  
delay ( 300);  
tone(buzzer, 660 ,100);  
delay ( 300);  
tone(buzzer, 510 ,100);  
delay ( 100);  
tone(buzzer, 660 ,100);  
delay ( 300);  
tone(buzzer, 770 ,100);  
delay ( 550);  
tone(buzzer, 380 ,100);  
delay ( 575);  
  
tone(buzzer, 510 ,100);  
delay ( 450);  
tone(buzzer, 380 ,100);  
delay ( 400);  
tone(buzzer, 320 ,100);  
delay ( 500);  
tone(buzzer, 440 ,100);  
delay ( 300);  
tone(buzzer, 480 ,80);  
delay ( 330);  
tone(buzzer, 450 ,100);  
delay ( 150);  
tone(buzzer, 430 ,100);  
delay ( 300);  
tone(buzzer, 380 ,100);  
delay ( 200);  
tone(buzzer, 660 ,80);  
delay ( 200);  
tone(buzzer, 760 ,50);  
delay ( 150);  
tone(buzzer, 860 ,100);  
delay ( 300);  
tone(buzzer, 700 ,80);  
delay ( 150);  
tone(buzzer, 760 ,50);  
delay ( 350);  
tone(buzzer, 660 ,80);  
delay ( 300);  
tone(buzzer, 520 ,80);  
delay ( 150);  
tone(buzzer, 580 ,80);  
delay ( 150);  
tone(buzzer, 480 ,80);  
delay ( 500);  
  
tone(buzzer, 510 ,100);  
delay ( 450);  
tone(buzzer, 380 ,100);  
delay ( 400);  
tone(buzzer, 320 ,100);  
delay ( 500);  
tone(buzzer, 440 ,100);  
delay ( 300);  
tone(buzzer, 480 ,80);  
delay ( 330);  
tone(buzzer, 450 ,100);  
delay ( 150);  
tone(buzzer, 430 ,100);  
delay ( 300);  
tone(buzzer, 380 ,100);  
delay ( 200);  
tone(buzzer, 660 ,80);  
delay ( 200);  
tone(buzzer, 760 ,50);  
delay ( 150);  
tone(buzzer, 860 ,100);  
delay ( 300);  
tone(buzzer, 700 ,80);  
delay ( 150);  
tone(buzzer, 760 ,50);  
delay ( 350);  
tone(buzzer, 660 ,80);  
delay ( 300);  
tone(buzzer, 520 ,80);  
delay ( 150);  
tone(buzzer, 580 ,80);  
delay ( 150);  
tone(buzzer, 480 ,80);  
delay ( 500);  
  
tone(buzzer, 500 ,100);  
delay ( 300);  
  
tone(buzzer, 760 ,100);  
delay ( 100);  
tone(buzzer, 720 ,100);  
delay ( 150);  
tone(buzzer, 680 ,100);  
delay ( 150);  
tone(buzzer, 620 ,150);  
delay ( 300);  
  
tone(buzzer, 650 ,150);  
delay ( 300);  
tone(buzzer, 380 ,100);  
delay ( 150);  
tone(buzzer, 430 ,100);  
delay ( 150);  
  
tone(buzzer, 500 ,100);  
delay ( 300);  
tone(buzzer, 430 ,100);  
delay ( 150);  
tone(buzzer, 500 ,100);  
delay ( 100);  
tone(buzzer, 570 ,100);  
delay ( 220);  
  
tone(buzzer, 500 ,100);  
delay ( 300);  
  
tone(buzzer, 760 ,100);  
delay ( 100);  
tone(buzzer, 720 ,100);  
delay ( 150);  
tone(buzzer, 680 ,100);  
delay ( 150);  
tone(buzzer, 620 ,150);  
delay ( 300);  
  
tone(buzzer, 650 ,200);  
delay ( 300);  
  
tone(buzzer, 1020 ,80);  
delay ( 300);  
tone(buzzer, 1020 ,80);  
delay ( 150);  
tone(buzzer, 1020 ,80);  
delay ( 300);  
  
tone(buzzer, 380 ,100);  
delay ( 300);  
tone(buzzer, 500 ,100);  
delay ( 300);  
  
tone(buzzer, 760 ,100);  
delay ( 100);  
tone(buzzer, 720 ,100);  
delay ( 150);  
tone(buzzer, 680 ,100);  
delay ( 150);  
tone(buzzer, 620 ,150);  
delay ( 300);  
  
tone(buzzer, 650 ,150);  
delay ( 300);  
tone(buzzer, 380 ,100);  
delay ( 150);  
tone(buzzer, 430 ,100);  
delay ( 150);  
  
tone(buzzer, 500 ,100);  
delay ( 300);  
tone(buzzer, 430 ,100);  
delay ( 150);  
tone(buzzer, 500 ,100);  
delay ( 100);  
tone(buzzer, 570 ,100);  
delay ( 420);  
  
tone(buzzer, 585 ,100);  
delay ( 450);  
  
tone(buzzer, 550 ,100);  
delay ( 420);  
  
tone(buzzer, 500 ,100);  
delay ( 360);  


 } //if the sensor senses water then play an alarm
 {
  val = analogRead(potpin);            
  val = map(val, 0, 1023, 0, 360);     
  myservo.write(val);                  
  delay(15);                         
}

}

Schematics

Comments

Similar projects you might like

All About Servo Motors and Servo Motor Tester

Project tutorial by RoboCircuits

  • 1,434 views
  • 0 comments
  • 7 respects

Temperature Sensor To control Servo Motor

by Jasleen

  • 6,407 views
  • 2 comments
  • 10 respects

How To Use DS18B20 Water Proof Temperature Sensor

Project showcase by IoTBoys

  • 68,489 views
  • 13 comments
  • 20 respects

Obstacles Avoiding Robot With Servo Motor

Project tutorial by Sora JY

  • 9,346 views
  • 3 comments
  • 26 respects

Arduino-Based Automatic Water Tap Using IR Sensor

Project tutorial by Creatjet3D R&D Team

  • 9,351 views
  • 6 comments
  • 22 respects

Arduino/Android - BLUETOOTH Multi Servo Motor Control

Project tutorial by Danny van den Brande

  • 16,284 views
  • 11 comments
  • 26 respects
Add projectSign up / Login