Hi there,
My project is pretty simple : I want to control a servo from an ethernet connection (a computer connected with ethernet)
Th servo is a DG servo S05NF
http://www.robotshop.com/eu/fr/servomoteur-s05nf-std.html
I've made this program
#include <SPI.h> // needed for Arduino versions later than 0018
#include <Ethernet.h>
#include <EthernetUdp.h> // UDP library from: bjoern@cs.stanford.edu 12/30/2008
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
int pos = 1; // variable to store the servo position
// Enter a MAC address and IP address for your controller below.
// The IP address will be dependent on your local network:
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192, 168, 10, 177);
unsigned int localPort = 8888; // local port to listen on
// buffers for receiving data
char packetBuffer[UDP_TX_PACKET_MAX_SIZE]; //buffer to hold incoming packet,
// An EthernetUDP instance to let us send and receive packets over UDP
EthernetUDP Udp;
void setup() {
// start the Ethernet and UDP:
Ethernet.begin(mac,ip);
Udp.begin(localPort);
myservo.attach(6); // attaches the servo on pin 7 to the servo object
myservo.write(pos);
Serial.begin(9600);
}
void loop() {
// if there's data available, read a packet
int packetSize = Udp.parsePacket();
if(packetSize)
{
// read the packet into packetBufffer
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
if (packetBuffer[0] == 'o') pos = 170;
else if (packetBuffer[0] == 'f') pos = 3;
}
if (pos>80) digitalWrite(9,HIGH);
else digitalWrite(9,LOW);
myservo.write(pos);
delay(500);
}
This is working when the board is connected (and powered) to the FTDI/usb adapter
BUT
when the board is powered from an external power adapter (I've try a 9v and a 12v). When I call the 0° position, the servo is reaching the 0° position, stand by half a second and reach the 180° back and is making noise like it's searching its position, and, about 2 seconds later stop searching (and making noise).
It's really curious.
I'm interested in any ideas.