Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * UIPEthernet UdpServer example.
- *
- * UIPEthernet is a TCP/IP stack that can be used with a enc28j60 based
- * Ethernet-shield.
- *
- * UIPEthernet uses the fine uIP stack by Adam Dunkels <adam@sics.se>
- *
- * -----------------
- *
- * This UdpServer example sets up a udp-server at 192.168.0.6 on port 5000.
- * send packet via upd to test
- *
- * Copyright (C) 2013 by Norbert Truchsess (norbert.truchsess@t-online.de)
- */
- int in1=A0,in2=A1,in3=A2,in4=A3,in5=A4,in6=A5,in7=6,in8=7;
- #include <UIPEthernet.h>
- EthernetUDP udp;
- int tempo;
- String c;
- void setup() {
- pinMode(in1, INPUT_PULLUP);
- pinMode(in2, INPUT_PULLUP);
- pinMode(in3, INPUT_PULLUP);
- pinMode(in4, INPUT_PULLUP);
- pinMode(in5, INPUT_PULLUP);
- pinMode(in6, INPUT_PULLUP);
- pinMode(in7, INPUT_PULLUP);
- pinMode(in8, INPUT_PULLUP);
- Serial.begin(9600);
- uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
- Ethernet.begin(mac,IPAddress(192,168,1,26));
- int success = udp.begin(5000);
- Serial.print("initialize: ");
- Serial.println(success ? "success" : "failed");
- }
- void loop() {
- String c;
- c+=digitalRead(in1);
- c+=digitalRead(in2);
- c+=digitalRead(in3);
- c+=digitalRead(in4);
- c+=digitalRead(in5);
- c+=digitalRead(in6);
- c+=digitalRead(in7);
- c+=digitalRead(in8);
- udp.beginPacket("192.168.1.27",4210);
- udp.print(c);
- Serial.println(c);
- udp.endPacket();
- delay(10);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement