hello
im using arduino uno with Ethernet Shield ENC28J60 RJ45.
i added the specials library and i can control leds via webserver.
i tried to control servo but when i add the commands of servo(servo.write(num)) the website cant be loaded.
can somone please help me?
thank you
Show your sketch.
//
#include "etherShield.h"
#include "ETHER_28J60.h"
#include <Servo.h>
int outputPin = 7;
static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // this just needs to be unique for your network,
// so unless you have more than one of these boards
// connected, you should be fine with this value.
static uint8_t ip[4] = {192, 168, 1, 15}; // the IP address for your board. Check your home hub
// to find an IP address not in use and pick that
// this or 10.0.0.15 are likely formats for an address
// that will work.
static uint16_t port = 80; // Use port 80 - the standard for HTTP
Servo m;
ETHER_28J60 e;
void setup()
{
e.setup(mac, ip, port);
pinMode(outputPin, OUTPUT);
m.attach(6);
}
void loop()
{
char* params;
if (params = e.serviceRequest())
{
e.print("<H1>Web Remote</H1>");
if (strcmp(params, "?cmd=on") == 0)
{
m.write(0);//----------// without this line it work just fine
digitalWrite(outputPin, HIGH);
e.print("<A HREF='?cmd=off'>Turn off</A>");
}
else if (strcmp(params, "?cmd=off") == 0)
{
m.write(180);//---------// without this line it work just fine
digitalWrite(outputPin, LOW);
e.print("<A HREF='?cmd=on'>Turn on</A>");
}
e.respond();
}
}
I don't see any obvious problems so I would suspect that the problem is running out of SRAM. My understanding is that the ENC28J60 only implements the low-level Ethernet protocol, leaving the library to implement the TCP/IP layers. This uses a LOT of resources.
You might want to consider buying an official Arduino Ethernet Shield R3 (or cheap clone thereof). The W5100 chip includes the TCP/IP stack and a 16K buffer. That leaves many more resources available for the Arduino sketch. You can get a clone through eBay for under $10.
thank you