(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:
Code:
#include <Servo.h>
Servo myservo;
void setup() {
// put your setup code here, to run once:
myservo.attach(9);
myservo.write(0); //sets the servo arm to the base position of 0 degrees
}
void loop() {
myservo.write(90);
delay(1500);
myservo.write(0);
delay(5000);
}
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
Hello,
Welcome to the Arduino Forum.
This guide explains how to get the best out of this forum. Please read and follow the instructions below.
Being new here you might think this is having rules for the sake of rules, but that is not the case. If you don’t follow the guidelines all that happens is there is a long exchange of posts while we try to get you to tell us what we need in order to help you, which is frustrating for you and frustrating for us.
The people who try to help with your pro…
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.
system
Closed
September 14, 2021, 12:37pm
#11
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.