Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /********* Pleasedontcode.com **********
- Pleasedontcode thanks you for automatic code generation! Enjoy your code!
- - Terms and Conditions:
- You have a non-exclusive, revocable, worldwide, royalty-free license
- for personal and commercial use. Attribution is optional; modifications
- are allowed, but you're responsible for code maintenance. We're not
- liable for any loss or damage. For full terms,
- please visit pleasedontcode.com/termsandconditions.
- - Project: Network Connection
- - Source Code NOT compiled for: Arduino Nano 33 BLE
- - Source Code created on: 2025-06-20 07:02:05
- ********* Pleasedontcode.com **********/
- /****** SYSTEM REQUIREMENTS *****/
- /****** SYSTEM REQUIREMENT 1 *****/
- /* Detect and initialize the Ethernet connection */
- /* using the Ethernet2 library and the W5500 module. */
- /* Retrieve and display the assigned IP address to */
- /* confirm successful connection. */
- /****** END SYSTEM REQUIREMENTS *****/
- /* START CODE */
- /****** DEFINITION OF LIBRARIES *****/
- #include <SPI.h>
- #include <Ethernet2.h> //https://github.com/adafruit/Ethernet2
- /****** FUNCTION PROTOTYPES *****/
- void setup(void);
- void loop(void);
- void updateOutputs(void);
- /***** DEFINITION OF DIGITAL OUTPUT PINS *****/
- const uint8_t ethernet_W5500_RST_PIN_D2 = 2;
- /***** DEFINITION OF SPI PINS *****/
- const uint8_t ethernet_W5500_SPI_PIN_MOSI_D11 = 11;
- const uint8_t ethernet_W5500_SPI_PIN_MISO_D12 = 12;
- const uint8_t ethernet_W5500_SPI_PIN_SCLK_D13 = 13;
- const uint8_t ethernet_W5500_SPI_PIN_CS_D10 = 10;
- /***** DEFINITION OF OUTPUT RAW VARIABLES *****/
- /***** used to store raw data *****/
- bool ethernet_W5500_RST_PIN_D2_rawData = 0;
- /***** DEFINITION OF OUTPUT PHYSICAL VARIABLES *****/
- /***** used to store data after characteristic curve transformation *****/
- float ethernet_W5500_RST_PIN_D2_phyData = 0.0;
- /****** LIBRARY OBJECT INSTANCES *****/
- // Instantiate Ethernet object
- EthernetClass Ethernet;
- /****** NETWORK CONFIGURATION *****/
- // Define static IP address (modify as needed)
- IPAddress localIp(192, 168, 1, 177); // Example IP address
- IPAddress dnsServer(8, 8, 8, 8); // Example DNS server (Google DNS)
- /****** SETUP FUNCTION *****/
- void setup(void)
- {
- // Initialize Ethernet connection
- Ethernet.init(ethernet_W5500_SPI_PIN_CS_D10); // Set CS pin
- int result = Ethernet.begin( /*mac address*/ NULL, localIp, dnsServer);
- if (result == 0)
- {
- Serial.begin(9600);
- Serial.println("Ethernet initialization failed");
- }
- else
- {
- Serial.begin(9600);
- Serial.print("Ethernet IP address: ");
- Serial.println(Ethernet.localIP());
- }
- // put your setup code here, to run once:
- pinMode(ethernet_W5500_RST_PIN_D2, OUTPUT);
- pinMode(ethernet_W5500_SPI_PIN_CS_D10, OUTPUT);
- // start the SPI library:
- SPI.begin();
- }
- /***** LOOP FUNCTION *****/
- void loop(void)
- {
- // put your main code here, to run repeatedly:
- updateOutputs(); // Refresh output data
- }
- /***** UPDATE OUTPUTS FUNCTION *****/
- void updateOutputs()
- {
- digitalWrite(ethernet_W5500_RST_PIN_D2, ethernet_W5500_RST_PIN_D2_rawData);
- }
- /* END CODE */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement