In this tutorial, I will explain how to use ENC28J60 ethernet module.
To use this module with Arduino, I will use EtherCard library. In this tutorial, I will make a simple code on Arduino, so a PC that connected to network can do a ping test to the Arduino.
First thing to do is connect the ENC28J60 to Arduino using this connection:
#include <EtherCard.h> static byte mac[] = { 0x74, 0x69, 0x69, 0x2D, 0x30, 0x31 }; static byte ip[] = { 192, 168, 1, 10 }; byte Ethernet::buffer[500]; void setup () { if (ether.begin(sizeof Ethernet::buffer, mac, 8) == 0) Serial.println("Failed to access Ethernet controller"); if (!ether.staticSetup(ip)) Serial.println("Failed to set IP address"); } void loop() { ether.packetLoop(ether.packetReceive()); }
To do a ping test from PC, you must configure the IP address of the PC. I am using this setting for my PC.
After setting IP for the PC, you can do a ping test from cmd. The result is like this:
No comments :
Post a Comment