Tutorial: Servo Auto Spray

It´s Summer time!!!! (it means we have some crazy hot days in Madrid… 40º C!!!!)

This summer has been quite complicated in Spain, and in my flat i don´t have air conditioning, so i needed to have a solution fast, since the fan was not doing enough… i came up with this simple one:



This was my view before the idea:

2014-07-18 17.29.30


But i got bored very fast of spraying myself while working… it was an endless loop… until it ocurred to me… “Put a servo on it, sprays love servos” (or something like that… and came up whit a very simple project. Well, you know “necessity is the base for inventions!” (and i didn´t had at hand a water pump and hoses for this, so servo it is!)

The parts:

1x Spray manual
1x Strong Servo (this one is TowerPro MG995
1x Aluminium servo base
1x Arduino UNO
1x Servo Shield (i should have used it, but since is only 1 movement per 30 sec, the power regulator of the Arduino is holding up, so i didn´t used it)
1x extra hardware, screws and bolts.

2014-07-18 19.33.02

It was a fast and very simple project. Just install the Servo Base on the bottle

2014-07-18 19.36.30

Install some hardware on the handle of the Spray. Take in acount this spray has 360 degrees of freedom on the top, so you will need to connect the servo in both sides to avoid rotation instead of pressure. Also some simple wire to connect the hardware to the servo.


2014-07-18 19.54.10

And we have our prototype!

2014-07-18 20.43.28


The Code:

// Based on the Sweep Example Code by BARRAGAN <http://barraganstudio.com>
// Modified by @mrlndr for @arduinoarts
// This example code is in the public domain.


Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created

int pos = 0; // variable to store the servo position
int del = 30000; // time between each spray in ms – 30000ms is 30 seg.

void setup()
myservo.attach(9); // attaches the servo on pin 9 to the servo object

void loop()
for(pos = 70; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable ‘pos’ delay(15); // waits 15ms for the servo to reach the position } delay(del); // waits the value of del for delay between sprays for(pos = 180; pos>=70; pos-=5) // goes from 180 degrees to 0 degrees
myservo.write(pos); // tell servo to go to position in variable ‘pos’
delay(1); // waits 15ms for the servo to reach the position

Related Posts

  • Just an amazing project to do with your Arduino (or compatible) board... one image (or a video) is worth more than a thousand words this time. (Video Below). You can say this is a "full time" job for an arduino... and in the end, a clock work is timeless? ;)…
  • uArm: Put a Miniature Industrial Robot Arm on Your Desk uArm is an Arduino-powered desktop 4-axis parallel-mechanism robot arm, modeled after the ABB industrial PalletPack robot. It is made up of laser cut acrylic or wood parts, powered by standard RC hobby servos, and controlled by an Arduino-compatible board. In…
  • Well, it´s finally here. I made a first working version of the lamp for the SeeedStudio.com Toy Hack Contest which ends this weekend!. http://www.youtube.com/watch?v=hmSlk4zmhYo Here are a few of the improvements i have done on the lamp (check the details on the photo gallery below): -Improved the fix on the…