查看“Microduino ENC Network (1)”的源代码
←
Microduino ENC Network (1)
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{{Language | Microduino ENC网络(一)}} {| style="width: 800px;" |- | ==Objective== This tutorial will show you how to ping the Microduino. ==Equipment== *'''[[Microduino-Core]]''' *'''[[Microduino-FT232R]]''' *'''[[Microduino-ENC28J60]]''' *'''[[Microduino-RJ45]]''' *Other equipment **USB cable ==Schematic== *Microduino-ENC28J60 *Microduino-RJ45 *Microduino-Core *Microduino-FT232R {|class="wikitable" ! rowspan="1" | ENC28J60 module || Microduino Pin || Function |- | SCK|| D13 || SPI bus clock |- | SI || D12 || Data input pin |- | SO || D11 || Data output pin |- | CS || D8 || SPI chip select (Defined in program) |- | INT || D2 || interrupt (INT0) |- | RST || RST || reset |} Stack all modules and then connect the ethernet cable, as follows: [[File:MicroduinoENCShow.jpg|600px|center|thumb]] ==Program== Download the program: https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_ENC/ENCnetworkone ==Debug== Step 1: Download the EtherCard library and copy to your libraries fold of IDE, then restart IDE. https://github.com/jcw/ethercard Step 2: Before connect to network, you need learn some network parameter. '''Network parameter:''' Before connecting Ethernet shield to the net, you need some parameters: *MAC address, is a 48bit number that univocally identify each device in the net. Every company that produces network devices owns a code (OUI) that represents the address’ first 24bits; *IP address, is a 32bit number (IPv4) that identify the device in the local network; *Subnet mask is a 32bit number that allows devices to know if another device belongs to the same local network; *(usually) gateway is the IP address assigned to a device (router…) that allows to reach devices in different networks. You need to choose a MAC address not already used in your network… in the examples we usually choose MAC addresses with a not already assigned organization code (es. DD-DD-DD). IP parameters (address, subnet, gateway) have to be consistent with the ones configured to other devices in your local network: an unique IP address and the same subnet mask and gateway. Sometimes a DHCP server is available, that automatically configures new devices in the network: in a next example I’m going to show how to use this with Arduino. Step 3: Explain the program. //First you need to include the EtherCard library and define some variables: MAC address, IP address and a buffer the library will use to store incoming and outgoing data; include <EtherCard.h> static byte mymac[] = {0x74,0x69,0x69,0x2D,0x30,0x31}; static byte myip[] = {192,168,1,10}; byte Ethernet::buffer[700]; ether.staticSetup(myip); //complete configuration with a static configuration for the IP address. Use the function staticSetup() method to configure the static IP, it has three parameters, that are ip address, gateway and DNS. IP is mandatory, others are optional. The following is the defination. static bool staticSetup (const uint8_t* my_ip =0, const uint8_t* gw_ip =0, const uint8_t* dns_ip =0); //in the loop, you need only 2 instructions: //packetReceive()method receives a new incoming packet from the network; //packetLoop() method answers to specific incoming messages, including the “ping” ones (ICMP echo request) ether.packetLoop(ether.packetReceive()); Step 4: Download the program and compile it. Step 5: ping! Check a device if has online, the "ping" command is a simple method. Ping the destination device's IP. [[File:cmdPing.jpg|600px|center|thumb]] ==Result== The upper picture indicates that the device has obeen online. ==Video== |}
该页面使用的模板:
模板:Language
(
查看源代码
)
模板:Nmbox
(
查看源代码
)
返回至
Microduino ENC Network (1)
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息