Pages: [1]   Go Down
Author Topic: Motor stop  (Read 551 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I use ATMega 2560. I use the default program sweep for servo. I want my servo to to 0 to 180 non stop in loop. So it works but only for 5 minutes and I want it like for ever. What's wrong please ? Thank you

Code:
// Sweep
// by BARRAGAN <http://barraganstudio.com>
// This example code is in the public domain.


#include <Servo.h>
 
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
 
void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}
 
 
void loop()
{
  for(pos = 0; 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(6);                       // waits 15ms for the servo to reach the position
  }
  for(pos = 180; pos>=1; pos-=1)     // goes from 180 degrees to 0 degrees
  {                               
    myservo.write(pos);              // tell servo to go to position in variable 'pos'
    delay(6);                       // waits 15ms for the servo to reach the position
  }
}
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50833
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

How is your servo wired? How is your servo powered? How is your Arduino powered?

There is nothing wrong with the code, so it must be a hardware problem.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Servo is wired with the servo wire (3pin female) directly on a ShieldV4 on my board. So the servo is powered with the board. The board is powered trought the usb port of my laptop.
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50833
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Servo is wired with the servo wire (3pin female) directly on a ShieldV4 on my board.
No idea what a ShieldV4 is. A link would be useful.

Quote
So the servo is powered with the board. The board is powered trought the usb port of my laptop.
Servos can take a lot of current - more than a USB port can supply. The computer is protecting itself turning off power to the Arduino.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 12
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is the shield V4 for arduino :

http://www.ebay.ca/itm/Arduino-UNO-MEGA-Duemilanove-Sensor-Shield-V4-Digital-Analog-Module-Servo-Motor-/181014763507?pt=LH_DefaultDomain_0&hash=item2a255217f3

There is still led on when the servo stop. Does the laptop still send a little power ?
Logged

Seattle, WA USA
Offline Offline
Brattain Member
*****
Karma: 650
Posts: 50833
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
There is still led on when the servo stop. Does the laptop still send a little power ?
Which LED?
Logged

Porto
Offline Offline
Newbie
*
Karma: 0
Posts: 30
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

you should post the schematics or your circuit for anyone understand and can help you...
which servo are you using?
Logged

For some Awesome Arduino Projects  click -> www.randomnerdtutorials.com

Pages: [1]   Go Up
Jump to: