Hola amigos,
El motivo de mi mensaje es por lo siguiente:
He adquirido un módulo arduino uno con un shield de Ethernet, tengo algo de experiencia en microcontroladores, pero los módulos arduinos son nuevos para mí. El problema es el siguiente, he probado algún programilla como encender un led y apagarlo con el puerto serie y me ha funcionado a la primera, pero luego estoy intentando hacer lo mismo pero a través del módulo shield y me estoy volviendo loco. Resulta que tengo el siguiente código:
#include <Ethernet.h>
#include <SPI.h>
boolean reading = false;
////////////////////////////////////////////////////////////////////////
//CONFIGURE
////////////////////////////////////////////////////////////////////////
byte ip[] = { 192, 168, 0, 199 }; //ip address to assign the arduino
byte gateway[] = { 192, 168, 0, 1 }; //ip address of the gatewa or router
//Rarly need to change this
byte subnet[] = { 255, 255, 255, 0 };
// if need to change the MAC address (Very Rare)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
Server server = Server(80); //port 80
////////////////////////////////////////////////////////////////////////
void setup(){
//Pins 10,11,12 & 13 are used by the ethernet shield
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
}
void loop(){
// listen for incoming clients, and process qequest.
checkForClient();
}
void checkForClient(){
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean currentLineIsBlank = true;
boolean sentHeader = false;
while (client.connected()) {
if (client.available()) {
if(!sentHeader){
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
sentHeader = true;
}
char c = client.read();
if(reading && c == ' ') reading = false;
if(c == '?') reading = true; //found the ?, begin reading the info
if(reading){
Serial.print(c);
switch (c) {
case '2':
//add code here to trigger on 2
triggerPin(2, client);
break;
case '3':
//add code here to trigger on 3
triggerPin(3, client);
break;
case '4':
//add code here to trigger on 4
triggerPin(4, client);
break;
case '5':
//add code here to trigger on 5
triggerPin(5, client);
break;
case '6':
//add code here to trigger on 6
triggerPin(6, client);
break;
case '7':
//add code here to trigger on 7
triggerPin(7, client);
break;
case '8':
//add code here to trigger on 8
triggerPin(8, client);
break;
case '9':
//add code here to trigger on 9
triggerPin(9, client);
break;
}
}
if (c == '\n' && currentLineIsBlank) break;
if (c == '\n') {
currentLineIsBlank = true;
}else if (c != '\r') {
currentLineIsBlank = false;
}
}
}
delay(1); // give the web browser time to receive the data
client.stop(); // close the connection:
}
}
void triggerPin(int pin, Client client){
//blink a pin - Client needed just for HTML output purposes.
client.print("Turning on pin ");
client.println(pin);
client.print("
");
digitalWrite(pin, HIGH);
delay(25);
digitalWrite(pin, LOW);
delay(25);
}
---------------------------------Pues bien cuando le doy a verificar (Verify) me sale el siguiente error, y el problema no es solo con éste sino con cualquier ejemplo que cargo de la red, excepto los que vienen de ejemplo con el programa arduino 1.0.
error:
sketch_dec04b:1: error: cannot declare parameter 'client' to be of abstract type 'Client'
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: because the following virtual functions are pure within 'Client':
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:12: note: virtual size_t Client::write(uint8_t)
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:13: note: virtual size_t Client::write(const uint8_t*, size_t)
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:14: note: virtual int Client::available()
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:15: note: virtual int Client::read()
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:17: note: virtual int Client::peek()
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:18: note: virtual void Client::flush()
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:10: note: virtual int Client::connect(IPAddress, uint16_t)
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:11: note: virtual int Client::connect(const char*, uint16_t)
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:16: note: virtual int Client::read(uint8_t*, size_t)
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:19: note: virtual void Client::stop()
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:20: note: virtual uint8_t Client::connected()
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:21: note: virtual Client::operator bool()
sketch_dec04b:16: error: cannot allocate an object of abstract type 'Server'
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Server.h:4: note: because the following virtual functions are pure within 'Server':
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Print.h:48: note: virtual size_t Print::write(uint8_t)
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Server.h:6: note: virtual void Server::begin()
sketch_dec04b:16: error: cannot declare variable 'server' to be of abstract type 'Server'
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Server.h:4: note: since type 'Server' has pure virtual functions
sketch_dec04b.cpp: In function 'void checkForClient()':
sketch_dec04b:44: error: 'class Server' has no member named 'available'
sketch_dec04b:44: error: cannot declare variable 'client' to be of abstract type 'Client'
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
sketch_dec04b:74: error: cannot allocate an object of abstract type 'Client'
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
sketch_dec04b:78: error: cannot allocate an object of abstract type 'Client'
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
sketch_dec04b:82: error: cannot allocate an object of abstract type 'Client'
/Users/secu/Downloads/Arduino.app/Contents/Resources/Java/hardware/arduino/cores/arduino/Client.h:7: note: since type 'Client' has pure virtual functions
sketch_dec04b:86: error: cannot allocate an object of abstract type 'Client'
(....) da mas errores...
Por lo que estoy ahí estancado, alguien me podría decir que puede ser??? cargo mal las librerias?? hay error en el código??, estoy desesperado porque luego le cargo un ejemplo que viene con el programa con el webserver y no me da error... =(
Muchas gracias de antemano...