facebook pixel מדריך: ספריה - Ethernet - פונקציית ()localIP - www.4project.co.il
Main logo www.4project.co.il
כל הרכיבים לפרוייקט שלכם
עגלת קניות

העגלה ריקה

לקוחות נכבדים, אלה שעות הפעילות של המחסן במהלך פסח 2024:
ערב חג וחג ראשון (22-23/04) - המחסן סגור
חול המועד (24-25/04) - המחסן יפעל בין 8:00 עד 15:00
ערב חג וחג שני (28-29/04) - המחסן סגור
נחזור לפעילות רגילה ביום שלישי 30/04
חג שמח!

ספריה - Ethernet - פונקציית ()localIP


2022-06-14 13:01:38
פונקציית ()Ethernet.localIP משיגה את כתובת ה-IP של מגן ה-Ethernet. שימושי כשהכתובת מושגת בצורה אוטומטית משרת ה-DHCP.


תחביר

קוד: בחר הכל
Ethernet.localIP();

פרמטרים:
אין.

הפונקציה מחזירה כתובת IP של ההתקן.


דוגמה

קוד: בחר הכל
#include <SPI.h>
#include <Ethernet.h>

// Enter a MAC address for your controller below.
// Newer Ethernet shields have a MAC address printed on a sticker on the shield
byte mac[] = { 
  0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 };

// Initialize the Ethernet client library
// with the IP address and port of the server
// that you want to connect to (port 80 is default for HTTP):
EthernetClient client;

void setup() {
  // start the serial library:
  Serial.begin(9600);
  // start the Ethernet connection:
  if (Ethernet.begin(mac) == 0) {
    Serial.println("Failed to configure Ethernet using DHCP");
    // no point in carrying on, so do nothing forevermore:
    for(;;)
      ;
  }
  // print your local IP address:
  Serial.println(Ethernet.localIP());
}

void loop() {

}



ראו גם:

Ethernet

פירוט שפת תכנות לסביבת Arduino


עמוד זה הוא תרגום של ()Ethernet.localIP לפי רישיון Creative Commons Attribution-ShareAlike 3.0.