hi there
i have a problem..
this is my code:
#include <SPI.h>
#include <Ethernet.h>
#include "DHT.h"
#include <IRremote.h>
#include "ir.h"
#define DHTPIN 2 // DTH Sensor
#define DHTTYPE DHT22 // DHT 22 (AM2302)
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
IPAddress ip(10,86,100,201);
IRsend irsend;
EthernetServer server(16123);
DHT dht(DHTPIN, DHTTYPE);
void setup()
{
// Serial.begin(9600);
// while (!Serial)
// {
; // wait for serial port to connect. Needed for Leonardo-Board only
// }
Ethernet.begin(mac, ip);
server.begin();
dht.begin();
// Serial.print("server is at ");
// Serial.println(Ethernet.localIP());
}
void loop()
{
float h;
float t;
EthernetClient client = server.available();
if (client)
{
// Serial.println("new client");
h = dht.readHumidity();
t = dht.readTemperature();
// isNaN (not a number)
if (isnan(t) || isnan(h))
{
// Serial.println("ERROR: Failed to read from DHT");
}
String clientMsg = "";
String clientbuffer = "";
while (client.connected())
{
if (client.available())
{
char c = client.read();
clientMsg += c;
client.print(c);
// Serial.println(clientMsg);
if (c == '\n') // Zeilenende: \n
{
clientMsg.toUpperCase();
if (clientMsg.startsWith("GET "))
{
if (clientMsg.substring(4,9) == "KLIMA" )
{
client.print("Temperature:");
client.println(t);
client.print("Humidity:");
client.println(h);
}
}
if (clientMsg.startsWith("PUT "))
{
client.print("PUT: ");
clientbuffer = clientMsg.substring(4,8);
client.println(clientbuffer);
if (clientbuffer == "IR P")
{
irsend.sendRaw(S_pwr,68,38);
}
if (clientbuffer == "IR 1")
{ client.println("jap");
irsend.sendRaw(S_1,68,38); irsend.sendRaw(S_1,68,38); irsend.sendRaw(S_1,68,38);
}
if (clientbuffer == "IR 2")
{
irsend.sendRaw(S_2,68,38);
}
/* if (clientbuffer == "IR 3")
{
irsend.sendRaw(S_3,68,38);
}
if (clientbuffer == "IR 4")
{
irsend.sendRaw(S_4,68,38);
}
if (clientbuffer == "IR 5")
{
irsend.sendRaw(S_5,68,38);
}
if (clientbuffer == "IR 6")
{
irsend.sendRaw(S_6,68,38);
}
*/ if (clientbuffer == "IR 7")
{
irsend.sendRaw(S_7,68,38);
}
if (clientbuffer == "IR 9")
{
irsend.sendRaw(S_9,68,38);
}
if (clientbuffer == "IR 0")
{
irsend.sendRaw(S_0,68,38);
}
clientbuffer = "";
}
if (clientMsg.startsWith("BYE")) // byebye und tschüss
{
client.stop();
}
clientMsg = "";
delay(10);
client.stop();
}
}
}
delay(10);
client.stop();
// Serial.println("client disonnected");
}
}
this works fine..
but if i remove the comment (/* ........ */) am unable to connect to the arduino.. then, i comment out the same code, i am can connect... i have tested it 10x..
why? - This confuses me.. it's the same.. i can't understand this..