Ola a todos, estou com problema de conexão com o ENC28J60 Ao Arduino UNO,

Estou usando esse codgo exemplo, esta copilando tudo certo mais não consigo ligar o led, se alguns dos colegas poderem me da uma força!!!

o modulo que eu estou usando é esse da foto,

 O codgo que eu estou usando como exemplo é esse aqui

#include <EtherCard.h>

static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
static byte myip[] = {192,168,1,2};
byte Ethernet::buffer[700];

const int ledPin = 2;
boolean ledStatus;

char* on = "ON";
char* off = "OFF";
char* statusLabel;
char* buttonLabel;

void setup () {

Serial.begin(57600);
Serial.println("WebLed Demo");

if (!ether.begin(sizeof Ethernet::buffer, mymac, 8))
Serial.println( "Failed to access Ethernet controller");
else
Serial.println("Ethernet controller initialized");

if (!ether.staticSetup(myip))
Serial.println("Failed to set IP address");

Serial.println();

pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, LOW);
ledStatus = false;
}

void loop() {

word len = ether.packetReceive();
word pos = ether.packetLoop(len);

if(pos) {

if(strstr((char *)Ethernet::buffer + pos, "GET /?status=ON") != 0) {
Serial.println("Received ON command");
ledStatus = true;
}

if(strstr((char *)Ethernet::buffer + pos, "GET /?status=OFF") != 0) {
Serial.println("Received OFF command");
ledStatus = false;
}

if(ledStatus) {
digitalWrite(ledPin, HIGH);
statusLabel = on;
buttonLabel = off;
} else {
digitalWrite(ledPin, LOW);
statusLabel = off;
buttonLabel = on;
}

BufferFiller bfill = ether.tcpOffset();
bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\nPragma: no-cache\r\n\r\n"
"<html><head><title>WebLed</title></head>"
"<body>LED Status: $S "
"<a href=\"/?status=$S\"><input type=\"button\" value=\"$S\"></a>"
"</body></html>"
), statusLabel, buttonLabel, buttonLabel);
ether.httpServerReply(bfill.position());
}
}

Exibições: 630

Responder esta

Respostas a este tópico

// A simple web server that turn an LED on or off"

#include "etherShield.h"
#include "ETHER_28J60.h"

int outputPin = 6;

static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // this just needs to be unique for your network,

static uint8_t ip[4] = {192, 168, 1, 15}; // IP address for the webserver

static uint16_t port = 80; // Use port 80 - the standard for HTTP

ETHER_28J60 e;

void setup()
{
e.setup(mac, ip, port);
pinMode(outputPin, OUTPUT);
}

void loop()
{
char* params;
if (params = e.serviceRequest())
{
e.print("<h1><a href='/?led=off'>Arduino Web Remote</a></h1>");
if (strcmp(params, "?led=on") == 0)
{
digitalWrite(outputPin, HIGH);
e.print("<a href='?led=off'><button style='border: 1px solid #ff0000; border-left: 10px solid #ff0000' type='button'>LED IS ON</button></a>");
}
else if (strcmp(params, "?led=off") == 0)
{
digitalWrite(outputPin, LOW);
e.print("<a href='?led=on'><button style='border: 1px solid #000; border-left: 10px solid #000' type='button'>LED IS OFF</button></a>");
}
e.respond();
}
}

Oi CJN, boa tarde.

Eu tenho um modulo ENC28J60, mas de fabricação da OLIMEX.

https://www.olimex.com/Products/Modules/Ethernet/ENC28J60-H/

Acredito que ele seja igual ao seu:

http://blog.filipeflop.com/modulos/modulo-ethernet-enc28j60-arduino...

Tive muita dificuldade ao tentar usa-lo, e já estava pra desistir qdo encontrei este code deste link que 

postei ,e o mesmo funcionou aqui comigo.

Sei que não é exatamente o que voce quer fazer, mas pode usa-lo pelo mesnos para 

testar a comunicação entre o seu modulo e a rede ethernet.

Eu usei duas bibliotecas: 

#include "etherShield.h"     #include "ETHER_28J60.h"

E era aí que estava o grande problema.

Existem varias bibliotecas na net, mas só um tipo funcionou comigo.

Anexo os arquivos: o code que usei e bibliotecas.

Rui

Anexos

RSS

© 2024   Criado por Marcelo Rodrigues.   Ativado por

Badges  |  Relatar um incidente  |  Termos de serviço