Bem vamos la, o problema é o seguinte, tenho um enc28j60 que ta funcionado perfeito, no entanto ele não ta dando conta de subir minha pagina toda pro navegador... o que pensei, usar meu leitor de sd pra upar a pagina.
Primeiro problema, será que da certo?
Segundo, alguem sabe como liga isso(pinagem) ou tem um bom datasheet ai, tudo que achei nada presta :S
Tags:
Oi Vitor, então você consegue fazer o módulo de rede funcionar junto do módulo sd?
Será que você pode compartilhar o código?
Obrigado
Sérgio
Legal, quando puder...agradeço.
Estou tentando algo aqui também..se conseguir posto para o pessoal..
abraços.
Olá Victor, conseguiu o código?
Se tiver também as bibliotecas que usa seria bom, pois me parece que tem um pulo do gato lá também.
Obrigado
Sérgio
Olá Helder,
pois é, segui os exemplos da internet..ex:
SPI
pino UNO - SD - ENC28J60
4 SS(CS)
10 SS(CS)
11 MOSI MOSI
12 MISO MISO
13 SCK SCK
Mas no código vc precisa desligar os pinos CS e liga no momento que vai utilizar, um de cada vez.
Essa é a questão, não consigo desligar os dispositivos, eles tentam utilizar os dispositivos de uma vez e isso não pode.
Segue código que estou testando:
#include <EtherCard.h>
#include <SPI.h>
#include <SD.h>
// Caso queira definir um ip estático mude de 0 para 1
#define STATIC 0
#if STATIC
// Endereço IP estático a ser definido a interface Ethernet
static byte myip[] = { 10,50,10,157 };
// Endereço IP do Gateway da sua rede
static byte gwip[] = { 10,50,10,1 };
#endif
// MAC Address da interface ethernet - deve ser único na sua rede local
static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x30 };
byte Ethernet::buffer[500];
const char page[] PROGMEM =
"HTTP/1.0 200 OK\r\n"
"Content-Type: text/html\r\n"
"Refresh: 5\r\n"
"\r\n"
"<html>"
" <head>"
" <title>Arduino Web Server</title>"
" </head>"
" <body>"
" <h3>Página resposta do seu Arduino.</h3>"
" <p><em>fabiotomio.com.br.<br />=D</em></p>"
" </body>"
"</html>"
;
const int chipSelectRede = 10;
const int SD_SS = 4;
//#define SD_SS 4
File myFile;
void setup(){
Serial.begin(9600);
Serial.println("\n[webserver]");
SPI.begin();
Serial.println("--- STATUS ---");
pinMode(chipSelectRede, OUTPUT); //8
digitalWrite(chipSelectRede, HIGH);
Serial.print("chipSelectRede apos pinMode = ");Serial.println(digitalRead(chipSelectRede));
pinMode(SD_SS, OUTPUT); //8
digitalWrite(SD_SS, HIGH);
Serial.print("SD_SS apos pinMode = ");Serial.println(digitalRead(SD_SS));
digitalWrite(SD_SS, HIGH);
digitalWrite(chipSelectRede, LOW);
if (ether.begin(sizeof Ethernet::buffer, mymac, chipSelectRede) == 0)
Serial.println( "Failed to access Ethernet controller");
#if STATIC
ether.staticSetup(myip, gwip);
#else
if (!ether.dhcpSetup())
Serial.println("DHCP failed");
#endif
ether.printIp("IP: ", ether.myip);
ether.printIp("GW: ", ether.gwip);
ether.printIp("DNS: ", ether.dnsip);
}
void testa_sd(){
Serial.print("Initializing SD card...");
if (!SD.begin(SD_SS)) {
Serial.println("initialization failed!");
return;
}
Serial.println("initialization done.");
if (SD.exists("example.txt")) {
Serial.println("example.txt exists.");
}
// open a new file and immediately close it:
Serial.println("Creating example.txt...");
myFile = SD.open("example.txt", FILE_WRITE);
myFile.close();
// chech if the file created
if (SD.exists("example.txt")){
Serial.println("example.txt createdexists.");
}
else {
Serial.println("example.txt doesn't exist.");
}
}
void loop(){
digitalWrite(SD_SS, LOW);
Serial.print("SD_SS antes de escrever = ");Serial.println(digitalRead(SD_SS));
testa_sd();
digitalWrite(SD_SS, HIGH);
Serial.print("SD_SS apos escrever = ");Serial.println(digitalRead(SD_SS));
/* if (ether.packetLoop(ether.packetReceive())) {
memcpy_P(ether.tcpOffset(), page, sizeof page);
ether.httpServerReply(sizeof page - 1);
}
*/
}
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por