Advertisement
Guest User

Untitled

a guest
Sep 24th, 2018
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. /*
  2. * UIPEthernet UdpServer example.
  3. *
  4. * UIPEthernet is a TCP/IP stack that can be used with a enc28j60 based
  5. * Ethernet-shield.
  6. *
  7. * UIPEthernet uses the fine uIP stack by Adam Dunkels <adam@sics.se>
  8. *
  9. * -----------------
  10. *
  11. * This UdpServer example sets up a udp-server at 192.168.0.6 on port 5000.
  12. * send packet via upd to test
  13. *
  14. * Copyright (C) 2013 by Norbert Truchsess (norbert.truchsess@t-online.de)
  15. */
  16. int in1=A0,in2=A1,in3=A2,in4=A3,in5=A4,in6=A5,in7=6,in8=7;
  17. #include <UIPEthernet.h>
  18.  
  19. EthernetUDP udp;
  20. int tempo;
  21. String c;
  22. void setup() {
  23.  
  24. pinMode(in1, INPUT_PULLUP);
  25. pinMode(in2, INPUT_PULLUP);
  26. pinMode(in3, INPUT_PULLUP);
  27. pinMode(in4, INPUT_PULLUP);
  28. pinMode(in5, INPUT_PULLUP);
  29. pinMode(in6, INPUT_PULLUP);
  30. pinMode(in7, INPUT_PULLUP);
  31. pinMode(in8, INPUT_PULLUP);
  32.  
  33. Serial.begin(9600);
  34.  
  35. uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
  36.  
  37. Ethernet.begin(mac,IPAddress(192,168,1,26));
  38.  
  39. int success = udp.begin(5000);
  40.  
  41. Serial.print("initialize: ");
  42. Serial.println(success ? "success" : "failed");
  43.  
  44. }
  45.  
  46. void loop() {
  47. String c;
  48. c+=digitalRead(in1);
  49. c+=digitalRead(in2);
  50. c+=digitalRead(in3);
  51. c+=digitalRead(in4);
  52. c+=digitalRead(in5);
  53. c+=digitalRead(in6);
  54. c+=digitalRead(in7);
  55. c+=digitalRead(in8);
  56. udp.beginPacket("192.168.1.27",4210);
  57. udp.print(c);
  58. Serial.println(c);
  59. udp.endPacket();
  60.  
  61. delay(10);
  62.  
  63.  
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement