Society of Robots - Robot Forum
|
Robot Tutorials
|
FAQ
|
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
News:
Squirrels have fuzzy tails.
Home
Help
Search
Login
Register
Society of Robots - Robot Forum
»
Software
»
Software
»
Problem with servo scanning with Arduino
Print
Author
Topic: Problem with servo scanning with Arduino (Read 6584 times)
0 Members and 2 Guests are viewing this topic.
SUTO the G
Jr. Member
Posts: 42
Helpful? 0
Problem with servo scanning with Arduino
«
on:
June 09, 2013, 07:19:36 AM »
here is the code:
#include <Servo.h>
Servo scanner;
int scan_angle = 0; //angle that the scanning servo is at
void setup()
{
scanner.attach(3);
}
void loop()
{
if(scan_angle < 180) //overflow protection
{
scan_angle += 1; //turn right
scanner.write(scan_angle);
delay(15);
}
else
{
scan_angle = 0;
scanner.write(scan_angle);
delay(15);
}
}
I don`t understand why does my motor make smaller angular turns if I put delay(5). I am trying to make it to scan from 0 to 180 deg and when it reaches 180 to jump back to 0, but I want to make this as fast as possible. If I change the delay(15) to delay(5) it goes faster but it doesn`t seams to go to 180 deg only to 90. Why is this happening? What can I do to make it go to 180 deg fast. Someone please help me!
Logged
jlizotte
Jr. Member
Posts: 45
Helpful? 3
Re: Problem with servo scanning with Arduino
«
Reply #1 on:
June 09, 2013, 08:19:27 AM »
where's the delete key? lol
«
Last Edit: June 09, 2013, 08:27:23 AM by jlizotte
»
Logged
jwatte
Supreme Robot
Posts: 1,345
Helpful? 82
Re: Problem with servo scanning with Arduino
«
Reply #2 on:
June 09, 2013, 10:34:46 AM »
5 milliseconds between pulses may be too small, and the servo doesn't like it when there's not enough pause between each pulse.
If you want it to turn faster, try adding 2 instead of 1 for each iteration through the loop.
Logged
Print
Society of Robots - Robot Forum
»
Software
»
Software
»
Problem with servo scanning with Arduino
SMF spam
blocked by CleanTalk