Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SPI.h>
- #include <Ethernet2.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, 178, 177);
- // 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());
- }
- String buffer ="";
- char antwort[10];
- int index=0;
- bool stat;
- void loop() {
- EthernetClient client = server.available();
- while(client.connected())
- {
- while(client.available())
- {
- char c=client.read();
- buffer+=c;
- if (c=='\n'){buffer="";}
- else if (c=='\r')
- {
- if (buffer.indexOf("GET /?on">=0)) {
- Serial.print("es funktioniert");
- buffer ="";
- }
- }
- }
- }
- }
- boolean getData(EthernetClient c)
- {
- while(c.available())
- {
- char dataRec=c.read();
- if (index<=9)
- {
- antwort[index++]=dataRec;
- }
- else{
- stat = true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement