나는 간단한 Arduino 이더넷 프로그램을 작성 중이다. 이 프로그램은 서버에 HTTP GET 요청을 보낸 다음 서버가 "Hello World"를 에코하여 Arduino 이더넷을 통해 수신하고 Arduino 1.0.4 IDE의 직렬 모니터에 인쇄 할 수 있어야합니다. 다음은 유용한 정보입니다. Windows Server 2003에서 XAMPP 서버를 사용하고 있습니다./xampp/htdocs/xampp에 PHP 파일을 넣었으며 파일 이름은 rec.php입니다. rec.php의 내용은 내가이 메시지가 아두 이노에 프로그램을로드 한 후이는 아두 이노 프로그램PHP 파일에서 Arduino 이더넷 읽기
#include <Ethernet.h>
#include <SPI.h>
byte mac[] = {0x90, 0xA2, 0xDA, 0x00, 0x7E, 0xAE}
IPAddress server { 192, 168, 1, 223 };
IPAddress ipAddress { xxx,xxx,xxx,xxx };
IPAddress myDNS {8,8,8,8};
IPAddress myGateway{192,168,1,1};
IPAddress mySubnet{255,255,255,0};
EthernetClient client;
void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ipAddress, myDNS, myGateway, mySubnet);
delay(1000);
Serial.println("connecting");
if(client.connect(server, 80))
{
Serial.println("Connected");
client.println("GET /rec.php HTTP/1.1");
}
else
Serial.println("Not Connected");
}
void loop()
{
if(client.available())
{
char c = client.read();
Serial.println(c);
delay(1000);
}
else
{
Serial.println("Not Available");
delay(1000);
}
}
의 파일 내용이
<?php
echo "Hello World";
?>
입니다 직렬 모니터 "HTTP/1.1 400 Bad Request"에서 확인하십시오. 그 문제를 해결하는 방법에 대한 제안? 당신의 대답을 간단하게하십시오.