He creado un proyecto para el escudo de Ethernet básico y la comunicación del programa JAVA. Cuando intento compilar el código, aparece un error:
Default.ino: In function 'void setup()':
Default:33: error: a function-definition is not allowed here before '{' token
Default:76: error: expected '}' at end of input
Por favor ayuda.
Mi código:
#include <SPI.h>
#include <Ethernet.h>
byte mac[] = {
0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(192,168,1, 177);
IPAddress gateway(192,168,1, 1);
IPAddress subnet(255, 255, 0, 0);
int redled = 2;
int yellowled = 3;
int greenled = 4;
char c = 0;
EthernetServer server(23);
boolean alreadyConnected = false;
void setup() {
pinMode( redled, OUTPUT );
pinMode( yellowled, OUTPUT );
pinMode( greenled, OUTPUT );
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
Serial.begin(9600);
while (!Serial) {
;
Serial.println("Server Is Ready!");
Serial.print("IP Address: ");
Serial.println(Ethernet.localIP());
Serial.println("Ready For Connections!");
}
void loop() {
EthernetClient client = server.available();
if (client) {
if (!alreadyConnected) {
client.flush();
Serial.println("Client Connected To Server.");
alreadyConnected = true;
}
if( client.available() > 0 )
{
c = client.read();
switch( c )
{
case '1':
digitalWrite( redled, HIGH );
break;
case '2':
digitalWrite( redled, LOW );
break;
case '3':
digitalWrite( yellowled, HIGH );
break;
case '4':
digitalWrite( yellowled, LOW );
break;
case '5':
digitalWrite( greenled, HIGH );
break;
case '6':
digitalWrite( greenled, LOW );
break;
case '8':
digitalWrite( redled, LOW );
digitalWrite( yellowled, LOW );
digitalWrite( greenled, LOW );
break;
case '7':
digitalWrite( redled, HIGH );
digitalWrite( yellowled, HIGH );
digitalWrite( greenled, HIGH );
break;
}
}
}