Automatic door handle sanitiser

(this is my first experience using arduino) For a school project, i am making an automatic door handle sanitizer. The idea is that it will activate at set intervals. it will spray sanitizer on the door handle by using a servo to press down on a spray bottle. Right now, I have the servo going back and forth from 0 to 90 degrees does work but it just randomly stops until I press the reset button.

any help would be appreciated

servo im using:


#include <Servo.h>
Servo myservo;

void setup() {
// put your setup code here, to run once:
myservo.write(0); //sets the servo arm to the base position of 0 degrees

void loop() {



The easier you make it to read and copy the code the more likely it is that you will get help

Please follow the advice given in the link below when posting code

How is the servo powered ?

The servo is being powered off of an arduino nano which is plugged into my computer

It sounds like the program is crashing. I wonder if it's due to noise on the power lines from the servo.

It might be worth connecting a capacitor across the power lines to the servo, and another across the power leads to the arduino.

I think that might be a problem. Try powering it separately, but connect the 0V rails together (for the Arduino and servo).

Do not power the servo directly from the Arduino 5V pin. It cannot supply enough current for the Servo.

Use an external power supply such as 4 AA batteries in series

thank you, i will try both of your solutions!

Also ,thanks for the very quick replies, this is a great community

yep, just tried this and it works great. thanks a lot.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.