PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

LinkStatus.ino 1.1KB

il y a 3 ans
12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. Link Status
  3. This sketch prints the ethernet link status. When the
  4. ethernet cable is connected the link status should go to "ON".
  5. NOTE: Only WizNet W5200 and W5500 are capable of reporting
  6. the link status. W5100 will report "Unknown".
  7. Hardware:
  8. - Ethernet shield or equivalent board/shield with WizNet 5200/5500
  9. Written by Cristian Maglie
  10. This example is public domain.
  11. */
  12. #include <SPI.h>
  13. #include <Ethernet.h>
  14. void setup() {
  15. // You can use Ethernet.init(pin) to configure the CS pin
  16. //Ethernet.init(10); // Most Arduino shields
  17. //Ethernet.init(5); // MKR ETH shield
  18. //Ethernet.init(0); // Teensy 2.0
  19. //Ethernet.init(20); // Teensy++ 2.0
  20. //Ethernet.init(15); // ESP8266 with Adafruit Featherwing Ethernet
  21. //Ethernet.init(33); // ESP32 with Adafruit Featherwing Ethernet
  22. Serial.begin(9600);
  23. }
  24. void loop() {
  25. auto link = Ethernet.linkStatus();
  26. Serial.print("Link status: ");
  27. switch (link) {
  28. case Unknown:
  29. Serial.println("Unknown");
  30. break;
  31. case LinkON:
  32. Serial.println("ON");
  33. break;
  34. case LinkOFF:
  35. Serial.println("OFF");
  36. break;
  37. }
  38. delay(1000);
  39. }