Offline
Jr. Member
Karma: 0
Posts: 75
|
 |
« on: February 15, 2013, 02:55:50 pm » |
getting a - expected unqualified id before"{" token.. any ideas EthernetClient client; EthernetServer server(80);
void setup() { // start the Ethernet connection and the server: Ethernet.begin(mac, ip); server.begin(); }
{ // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. //lcd.print("W-");
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Online
Edison Member
Karma: 27
Posts: 1539
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #1 on: February 15, 2013, 02:57:52 pm » |
Full code?
|
|
|
|
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25382
Solder is electric glue
|
 |
« Reply #2 on: February 15, 2013, 02:59:46 pm » |
getting a - expected unqualified id before"{" token..
Where? It normally means you have missed out a semicolon on the line before.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 75
|
 |
« Reply #3 on: February 15, 2013, 03:01:20 pm » |
line 73... cheers //// // // General code from http://www.pushingbox.com for Arduino + Ethernet Shield (official) v1.2 // ////
#include <SPI.h> #include <Ethernet.h> #include <LiquidCrystal.h> #include "DHT.h" #define DHTPIN A1 // what pin we're connected to #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE);
///////////////// // MODIFY HERE // ///////////////// byte mac[] = { 0x00, 0x13, 0x02, 0xCC, 0xD1, 0x19 }; // Be sure this address is unique in your network byte ip[] = { 192,168,0, 101 };
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want char DEVID1[] = "v1CC65E36Dxxxx00"; //Scenario : 1 char DEVID2[] = "v9565F5FAAxxxx41"; //Scenario : 2
//Numeric Pin where you connect your switch #define pinDevid1 8// mm #define pinDevid2 9// mm
/// 4 6 11 12 13 14 // rs, en, D4, D5 D6 D7 LiquidCrystal lcd(A4, A5 , 3, 2, A3, A2);
int sensorPin = A0; // select the input pin for the detector //int countMAILW=0; int count = 0; int FED = 0; int countMAILF = 0;
int sensorValue = 0; // variable to store the value coming from the detector byte latch = 0; //initial variable const int pump = 4; const int fan = 5;
// Debug mode #define DEBUG true ////////////// // End // //////////////
char serverName[] = "api.pushingbox.com"; boolean pinDevid1State = false; boolean pinDevid2State = false; boolean lastConnected = false; // state of the connection last time through the main loop
// Initialize the Ethernet client library // with the IP address and port of the server // that you want to connect to (port 80 is default for HTTP): EthernetClient client; EthernetServer server(80);
void setup() { // start the Ethernet connection and the server: Ethernet.begin(mac, ip); server.begin(); }
{ // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. //lcd.print("W-");
Serial.begin(9600); pinMode(pinDevid1, OUTPUT);// pin 8 //pinMode(pinDevid2, INPUT);// pin 9 pinMode(fan, OUTPUT);// pinMode(pump, OUTPUT);// // pinMode(relay, OUTPUT); dht.begin();
// start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP");
lcd.setCursor(0,0); lcd.print("Disconnected ");
//while(true);// no point in carrying on, so do nothing forevermore:
} else{
Serial.println("Ethernet ready");
lcd.setCursor(0,0); lcd.print("Net OK "); delay(2000); lcd.clear();
Serial.print("My IP address: ");// print the Ethernet board/shield's IP address: Serial.println(Ethernet.localIP()); lcd.print(Ethernet.localIP()); delay(2000); lcd.clear(); FED=0; lcd.setCursor(10,0); lcd.print("F"); lcd.print(FED);
}
delay(500);// give the Ethernet shield a second to initialize: }}
void loop() Client client = server.available(); if (client) {
// an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println();
// output the value of each analog input pin for (int analogChannel = 0; analogChannel < 1; analogChannel++) { client.print("analog input "); client.print(analogChannel); client.print(" is "); client.print(analogRead(analogChannel)); client.println("<br />");
}
break;
}
if (c == '\n') {
// you're starting a new line currentLineIsBlank = true; } else if (c != '\r') {
// you've gotten a character on the current line currentLineIsBlank = false;
}
}
}
// give the web browser time to receive the data delay(1); // close the connection: client.stop();
}
} { float h = dht.readHumidity(); float t = dht.readTemperature(); // check if returns are valid, if they are NaN (not a number) then something went wrong! if (isnan(t) || isnan(h)) { Serial.println("Failed to read from DHT"); } else { Serial.print("Humidity: "); Serial.print(h); Serial.print(" % "); Serial.print("Temp: "); Serial.print(t); Serial.println("C"); }
// set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(8, 1); lcd.print("H:"); lcd.print(h); lcd.print("%"); //delay(2000); lcd.setCursor(0, 1); lcd.print("T:"); lcd.print(t); //lcd.print("C"); //delay(2000);
if(t>=26) { digitalWrite(fan, HIGH); lcd.setCursor(15, 0); lcd.print("F");} if(t<=24) { digitalWrite(fan, LOW); lcd.setCursor(15, 0); lcd.print("_");}
lcd.setCursor(0,0); lcd.print("W-"); lcd.setCursor(2,0);// (note: line 1 is the second row, since counting begins with 0): // print the number of seconds since reset: lcd.print(sensorValue);
sensorValue = analogRead(sensorPin); // read the value from the soil detector:
Serial.print("moisture sensor reads "); Serial.println( sensorValue ); delay(100);
if(sensorValue<750 && count==0) { //countMAILF=0; delay(2000); if(sensorValue<750 && count==0) delay(2000); digitalWrite(pinDevid1, HIGH); digitalWrite(pump, LOW); lcd.setCursor(14, 0); lcd.print("P"); delay(10000); digitalWrite(pump, HIGH); lcd.setCursor(14, 0); lcd.print("R"); //digitalWrite(pinDevid1, HIGH); } count++;// this increments the count by 1
if(sensorValue>800) //if(countMAILF ==0) {digitalWrite(pinDevid1, LOW); digitalWrite(pump, LOW); lcd.setCursor(14, 0); lcd.print("_"); count=0;}
if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false )// switch on pinDevid1 is ON {
if(DEBUG){ Serial.println("pinDevid1 is HIGH"); } pinDevid1State = true;
sendToPushingBox(DEVID1);//Sending request to PushingBox when the pin is HIGHT delay(500);
} delay(1000);
if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF { if(DEBUG){ Serial.println("pinDevid1 is LOW"); } pinDevid1State = false; sendToPushingBox(DEVID2); // digitalWrite(9, HIGH); } //digitalWrite(pump, LOW); delay(500); // countMAILF = val;
//DEBUG part // this write the respons from PushingBox Server. // You should see a "200 OK" if (client.available()) { char c = client.read(); if(DEBUG){ Serial.print(c); } }
// if there's no net connection, but there was one last time // through the loop, then stop the client: if (!client.connected() && lastConnected) { if(DEBUG){ Serial.println(); } if(DEBUG){ Serial.println("disconnecting."); } client.stop(); } lastConnected = client.connected(); }
//Function for sending the request to PushingBox void sendToPushingBox(char devid[]){ client.stop(); if(DEBUG){ Serial.println("connecting..."); lcd.setCursor(0,0); lcd.print("connecting.... "); delay(1000); }
if (client.connect(serverName, 80)) { if(DEBUG){ Serial.println("connected "); lcd.setCursor(0,0); lcd.print("connected "); delay(1000); }
if(DEBUG){ Serial.println("sendind request"); } client.print("GET /pushingbox?devid="); client.print(devid); client.println(" HTTP/1.1"); client.print("Host: "); client.println(serverName); client.println("User-Agent: Arduino"); client.println(); lcd.setCursor(0,0); lcd.print(" sent! "); delay(5000); lcd.clear(); }
else { if(DEBUG){ Serial.println("connection failed"); } }}}
|
|
|
|
« Last Edit: February 15, 2013, 03:02:58 pm by Hackdub »
|
Logged
|
|
|
|
|
California
Online
Edison Member
Karma: 37
Posts: 1827
|
 |
« Reply #4 on: February 15, 2013, 03:03:19 pm » |
Auto Format Failed: Too many right curly braces If you format your code in a more conventional way, this shouldn't be difficult to spot.
|
|
|
|
|
Logged
|
|
|
|
|
Seattle, WA USA
Offline
Brattain Member
Karma: 311
Posts: 35470
Seattle, WA USA
|
 |
« Reply #5 on: February 15, 2013, 03:03:59 pm » |
The correct ratio of answers to questions is a minimum of 1:1. You ratio is a bit less than that.
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Online
Edison Member
Karma: 27
Posts: 1539
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #6 on: February 15, 2013, 03:04:39 pm » |
The lack of proper formatting this code has, will haunt me in my dreams. No function? { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. //lcd.print("W-");
Serial.begin(9600); pinMode(pinDevid1, OUTPUT);// pin 8 //pinMode(pinDevid2, INPUT);// pin 9 pinMode(fan, OUTPUT);// pinMode(pump, OUTPUT);// // pinMode(relay, OUTPUT); dht.begin();
// start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP");
lcd.setCursor(0,0); lcd.print("Disconnected ");
//while(true);// no point in carrying on, so do nothing forevermore:
} else{
Serial.println("Ethernet ready");
lcd.setCursor(0,0); lcd.print("Net OK "); delay(2000); lcd.clear();
Serial.print("My IP address: ");// print the Ethernet board/shield's IP address: Serial.println(Ethernet.localIP()); lcd.print(Ethernet.localIP()); delay(2000); lcd.clear(); FED=0; lcd.setCursor(10,0); lcd.print("F"); lcd.print(FED);
}
|
|
|
|
« Last Edit: February 15, 2013, 03:06:51 pm by HazardsMind »
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
East Anglia (UK)
Offline
Edison Member
Karma: 46
Posts: 1380
May all of your blinks be without delay
|
 |
« Reply #7 on: February 15, 2013, 03:07:48 pm » |
Is this the full extent of the setup() function ? void setup() { // start the Ethernet connection and the server: Ethernet.begin(mac, ip); server.begin(); }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 75
|
 |
« Reply #8 on: February 15, 2013, 03:27:59 pm » |
OK lets start again.. I want to display some analogue values on a server, as well as using pushing box. so I want to combine this code // for W5100 ethernet shield // the IP address will be dependent on your local network/router // port 80 is default for HTTP, but can be changed as needed // use IP address like http://192.168.1.102/ in your brouser
#include <SPI.h> #include <Ethernet.h>
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; byte ip[] = { 192, 168, 1, 102 }; Server server(80);
void setup() { // start the server Ethernet.begin(mac, ip); server.begin(); }
void loop() { // listen for incoming clients Client client = server.available(); if (client) { while (client.connected()) { if (client.available()) { char c = client.read(); // see if HTTP request has ended with blank line if (c == '\n') { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println(); //meta-refresh page every 2 seconds client.print("<HEAD>"); client.print("<meta http-equiv=\"refresh\" content=\"2\">"); client.print("<TITLE />Zoomkat's meta-refresh test</title>"); client.print("</head>"); // output the value of each analog input pin for (int analogChannel = 0; analogChannel < 6; analogChannel++) { client.print("analog input "); client.print(analogChannel); client.print(" is "); client.print(analogRead(analogChannel)); client.println("<br />"); } break; } } } // give the web browser time to receive the data delay(1); // close the connection: client.stop(); } }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 75
|
 |
« Reply #9 on: February 15, 2013, 03:28:52 pm » |
and wanted to combine with my code with my code #include <SPI.h> #include <Ethernet.h> #include <LiquidCrystal.h> #include "DHT.h" #define DHTPIN A1 // what pin we're connected to #define DHTTYPE DHT11 // DHT 11 DHT dht(DHTPIN, DHTTYPE);
///////////////// // MODIFY HERE // ///////////////// byte mac[] = { 0x00, 0x13, 0x02, 0xCC, 0xD1, 0x19 }; // Be sure this address is unique in your network
//Your secret DevID from PushingBox.com. You can use multiple DevID on multiple Pin if you want char DEVID1[] = "v1CC65E36Dxxx00"; //Scenario char DEVID2[] = "v9565F5FAAxxx41"; //Scenario
//Numeric Pin where you connect your switch #define pinDevid1 8// Water #define pinDevid2 9// FED
/// 4 6 11 12 13 14 // rs, en, D4, D5 D6 D7 LiquidCrystal lcd(A4, A5 , 3, 2, A3, A2);
int sensorPin = A0; // select the input pin for the detector //int countMAILW=0; int count = 0; int FED = 0; int countMAILF = 0;
int sensorValue = 0; // variable to store the value coming from the detector byte latch = 0; //initial variable const int pump = 4; const int fan = 5;
// Debug mode #define DEBUG true ////////////// // End // //////////////
char serverName[] = "api.pushingbox.com"; boolean pinDevid1State = false; boolean pinDevid2State = false; boolean lastConnected = false; // state of the connection last time through the main loop
// Initialize the Ethernet client library // with the IP address and port of the server // that you want to connect to (port 80 is default for HTTP): EthernetClient client;
void setup() { // set up the LCD's number of columns and rows: lcd.begin(16, 2); // Print a message to the LCD. //lcd.print("W-");
Serial.begin(9600); pinMode(pinDevid1, OUTPUT);// pin 8 //pinMode(pinDevid2, INPUT);// pin 9 pinMode(fan, OUTPUT);// pinMode(pump, OUTPUT);// // pinMode(relay, OUTPUT); dht.begin();
// start the Ethernet connection: if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP");
lcd.setCursor(0,0); lcd.print("Disconnected ");
//while(true);// no point in carrying on, so do nothing forevermore:
} else{
Serial.println("Ethernet ready");
lcd.setCursor(0,0); lcd.print("Net OK "); delay(2000); lcd.clear();
Serial.print("My IP address: ");// print the Ethernet board/shield's IP address: Serial.println(Ethernet.localIP()); lcd.print(Ethernet.localIP()); delay(2000); lcd.clear(); FED=0; lcd.setCursor(10,0); lcd.print("F"); lcd.print(FED);
}
delay(500);// give the Ethernet shield a second to initialize: }
void loop() {
float h = dht.readHumidity(); float t = dht.readTemperature(); // check if returns are valid, if they are NaN (not a number) then something went wrong! if (isnan(t) || isnan(h)) { Serial.println("Failed to read from DHT"); } else { Serial.print("Humidity: "); Serial.print(h); Serial.print(" % "); Serial.print("Temp: "); Serial.print(t); Serial.println("C"); }
// set the cursor to column 0, line 1 // (note: line 1 is the second row, since counting begins with 0): lcd.setCursor(8, 1); lcd.print("H:"); lcd.print(h); lcd.print("%"); //delay(2000); lcd.setCursor(0, 1); lcd.print("T:"); lcd.print(t); //lcd.print("C"); //delay(2000);
if(t>=26)
{ digitalWrite(fan, HIGH); lcd.setCursor(15, 0); lcd.print("F"); }
if(t<=24)
{ digitalWrite(fan, LOW); lcd.setCursor(15, 0); lcd.print("_"); }
lcd.setCursor(0,0); lcd.print("W-"); lcd.setCursor(2,0);// (note: line 1 is the second row, since counting begins with 0): // print the number of seconds since reset: lcd.print(sensorValue);
sensorValue = analogRead(sensorPin); // read the value from the soil detector:
Serial.print("moisture sensor reads "); Serial.println( sensorValue ); delay(100);
if(sensorValue<750 && count==0) { //countMAILF=0; delay(2000); if(sensorValue<750 && count==0) delay(2000); digitalWrite(pinDevid1, HIGH); digitalWrite(pump, LOW); lcd.setCursor(14, 0); lcd.print("P"); delay(10000); digitalWrite(pump, HIGH); lcd.setCursor(14, 0); lcd.print("R"); //digitalWrite(pinDevid1, HIGH); } count++;// this increments the count by 1
if(sensorValue>800) //if(countMAILF ==0) { digitalWrite(pinDevid1, LOW); digitalWrite(pump, LOW); lcd.setCursor(14, 0); lcd.print("_"); count=0; }
if (digitalRead(pinDevid1) == HIGH && pinDevid1State == false )// switch on pinDevid1 is ON {
if(DEBUG){ Serial.println("pinDevid1 is HIGH"); } pinDevid1State = true;
sendToPushingBox(DEVID1);//Sending request to PushingBox when the pin is HIGHT delay(500);
} delay(1000);
if (digitalRead(pinDevid1) == LOW && pinDevid1State == true) // switch on pinDevid1 is OFF { if(DEBUG){ Serial.println("pinDevid1 is LOW"); } pinDevid1State = false; sendToPushingBox(DEVID2);
// digitalWrite(9, HIGH); } //digitalWrite(pump, LOW); delay(500);
// countMAILF = val;
//DEBUG part // this write the respons from PushingBox Server. // You should see a "200 OK" if (client.available()) { char c = client.read(); if(DEBUG){ Serial.print(c); } }
// if there's no net connection, but there was one last time // through the loop, then stop the client: if (!client.connected() && lastConnected) { if(DEBUG){ Serial.println(); } if(DEBUG){ Serial.println("disconnecting."); } client.stop(); } lastConnected = client.connected(); }
//Function for sending the request to PushingBox void sendToPushingBox(char devid[]){ client.stop(); if(DEBUG){ Serial.println("connecting..."); lcd.setCursor(0,0); lcd.print("connecting.... "); delay(1000); }
if (client.connect(serverName, 80)) { if(DEBUG){ Serial.println("connected "); lcd.setCursor(0,0); lcd.print("connected "); delay(1000); }
if(DEBUG){ Serial.println("sendind request"); } client.print("GET /pushingbox?devid="); client.print(devid); client.println(" HTTP/1.1"); client.print("Host: "); client.println(serverName); client.println("User-Agent: Arduino"); client.println(); lcd.setCursor(0,0); lcd.print(" sent! "); delay(5000); lcd.clear();
}
else { if(DEBUG){ Serial.println("connection failed"); } } }
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 75
|
 |
« Reply #10 on: February 15, 2013, 03:29:58 pm » |
sorry three replies due to charcter count.. the initial server code came from .. http://arduino.cc/forum/index.php?topic=70177.0;wap2but creates these errors sketch_feb15a:11: error: no matching function for call to 'Server::Server(int)' As of Arduino 1.0, the Server class in the Ethernet library has been renamed to EthernetServer. C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Server.h:4: note: candidates are: Server::Server() C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Server.h:4: note: Server::Server(const Server&) sketch_feb15a:11: error: cannot declare variable 'server' to be of abstract type 'Server' C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Server.h:4: note: because the following virtual functions are pure within 'Server': C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Print.h:48: note: virtual size_t Print::write(uint8_t) C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Server.h:6: note: virtual void Server::begin() sketch_feb15a.ino: In function 'void loop()': sketch_feb15a:23: error: 'class Server' has no member named 'available' sketch_feb15a:23: error: cannot declare variable 'client' to be of abstract type 'Client' C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:7: note: because the following virtual functions are pure within 'Client': C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:12: note: virtual size_t Client::write(uint8_t) C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:13: note: virtual size_t Client::write(const uint8_t*, size_t) C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:14: note: virtual int Client::available() C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:15: note: virtual int Client::read() C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:17: note: virtual int Client::peek() C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:18: note: virtual void Client::flush() C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:10: note: virtual int Client::connect(IPAddress, uint16_t) C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:11: note: virtual int Client::connect(const char*, uint16_t) C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:16: note: virtual int Client::read(uint8_t*, size_t) C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:19: note: virtual void Client::stop() C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:20: note: virtual uint8_t Client::connected() C:\Users\VJPC\Documents\arduino-1.0.3\hardware\arduino\cores\arduino/Client.h:21: note: virtual Client::operator bool()
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25382
Solder is electric glue
|
 |
« Reply #11 on: February 15, 2013, 03:59:21 pm » |
Close but no coconut. You gave two sketches and the error from when you tried to combine the two but you did not give the combined code that gave those error messages. For what you need to do to combine two sketches see here:- http://www.thebox.myzen.co.uk/Tutorial/Merging_Code.html
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 75
|
 |
« Reply #12 on: February 15, 2013, 04:07:49 pm » |
ok cheers mike...
Im getting errors on just the client... before i merge it.. it looks like its not compatible with my library.
|
|
|
|
|
Logged
|
|
|
|
|
Queens, New York
Online
Edison Member
Karma: 27
Posts: 1539
"Of all the things I've ever lost, I miss my mind the most" -Ozzy Osbourne
|
 |
« Reply #13 on: February 15, 2013, 04:10:14 pm » |
it looks like its not compatible with my library. Or you didn't put the library in the correct folder. What IDE are you using?
|
|
|
|
|
Logged
|
UNO, MEGA, NANO, 4x4 keypad, micro servos, RF transceivers, bluetooth, ultrasonic sensor, 20x4 I2C LCD, 3.2 TFT touch screen, L298N Dual motor driver, Voice Recognition 15W, Gameduino
Arduino Tutorials, coming soon.
"If your doing nothing, it does not mean your lazy, it just means your open for anything that suits you" - Unknown
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 75
|
 |
« Reply #14 on: February 15, 2013, 04:16:24 pm » |
1.03 ver OK made a lot of progess.. found a working client in examples... DOH ... /* Web Server A simple web server that shows the value of the analog input pins. using an Arduino Wiznet Ethernet shield. Circuit: * Ethernet shield attached to pins 10, 11, 12, 13 * Analog inputs attached to pins A0 through A5 (optional) created 18 Dec 2009 by David A. Mellis modified 9 Apr 2012 by Tom Igoe */
#include <SPI.h> #include <Ethernet.h>
// Enter a MAC address and IP address for your controller below. // The IP address will be dependent on your local network: byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192,168,0,7);
// Initialize the Ethernet server library // with the IP address and port you want to use // (port 80 is default for HTTP): EthernetServer server(80);
void setup() { // Open serial communications and wait for port to open: Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for Leonardo only }
// start the Ethernet connection and the server: Ethernet.begin(mac, ip); server.begin(); Serial.print("server is at "); Serial.println(Ethernet.localIP()); }
void loop() { // listen for incoming clients EthernetClient client = server.available(); if (client) { Serial.println("new client"); // an http request ends with a blank line boolean currentLineIsBlank = true; while (client.connected()) { if (client.available()) { char c = client.read(); Serial.write(c); // if you've gotten to the end of the line (received a newline // character) and the line is blank, the http request has ended, // so you can send a reply if (c == '\n' && currentLineIsBlank) { // send a standard http response header client.println("HTTP/1.1 200 OK"); client.println("Content-Type: text/html"); client.println("Connnection: close"); client.println(); client.println("<!DOCTYPE HTML>"); client.println("<html>"); // add a meta refresh tag, so the browser pulls again every 5 seconds: client.println("<meta http-equiv=\"refresh\" content=\"5\">"); // output the value of each analog input pin for (int analogChannel = 0; analogChannel < 6; analogChannel++) { int sensorReading = analogRead(analogChannel); client.print("analog input "); client.print(analogChannel); client.print(" is "); client.print(sensorReading); client.println("<br />"); } client.println("</html>"); break; } if (c == '\n') { // you're starting a new line currentLineIsBlank = true; } else if (c != '\r') { // you've gotten a character on the current line currentLineIsBlank = false; } } } // give the web browser time to receive the data delay(1); // close the connection: client.stop(); Serial.println("client disonnected"); } } Just struggling to get it to merge with my original code..... the loop part... just cant find the right place to drop it in. cheers David
|
|
|
|
« Last Edit: February 15, 2013, 05:00:16 pm by Hackdub »
|
Logged
|
|
|
|
|
|