X-Board控制器 兼容Arduino
<img alt="" src="http://images.ncnynl.com/arduino/2016/300px-X-board_1.jpg" width="300" height="292" class="thumbimage" /> <img src="http://images.ncnynl.com/arduino/2016/magnify-clip.png" width="15" height="11" alt="" />X-Board控制器 兼容Arduino(SKU:DFR0162)
目录
1 概 述
2 性能描述
3 LED指示灯定义
4 上传程序
5 Arduino测试样例
6 资料下载
概 述
X-board是一个独特的Arduino板,它提供的XBee插座,WIZnet以太网端口采用了ATMega328芯片。使用X-board将可以让你的项目通过XBee来控制并能和互联网链接。
使用X-board可以应用于家庭自动化到机器人控制等项目。没有什么是不可能的!
X-board具有8路模拟量I/O引脚和8个数字引脚,其中4个具有PWM(以星号表示),它的XBee插座完美的兼容所有的XBee模块,同时也兼容APC220 RF无线模块和DF-Bluetooth模块。
X-board能通过FTDI编程器或者直接通过ICSP接线端进行编程。X-board通过Mini USB接口提供电源。
你可以在X-board上设置一个Web服务器,通过X-board您可以与远程使用的XBee模块,蓝牙模块或APC模块进行通信。采集的信息可以发送到网站或发微薄。
我们在办公室利用X-board制作了一个项目,通过X-board我们能在网上控制办公室的门。如果我们忘记了我们的RFID门禁卡,那我们只要登录到我们的办公室无线网络并发送一个开门的命令,芝麻开门!门就应声而开!
我们已经创建了一个教程,其中包括零件清单,源代码可以上下载。
性能描述
控制芯片:Atmega328P low voltage version (8Mhz)
以太网控制芯片:WIZ5100
Arduino引导程序:Arduino Duemilanove bootlaoder
电源电压:3.6~12v
输出电压:3.3v
数字IO口: 8
模拟口: 8
LED指示灯定义
PWR: 电源指示灯
LINK: 指示网络链接状况,当接收或发送数据时闪烁
FULLD: 指示网络链接是否全双工
100M: 指示10m/100m网络链接
RX: 数据接收时闪烁
TX: 数据发送时闪烁
COLL: 网络冲突时闪烁
上传程序
注意事项:X-board需要一个FTDI板来上传程序
Arduino测试样例
#include <Client.h>
#include <Ethernet.h>
#include <Server.h>
#include <Udp.h>
#include <SPI.h>
/*
- Web Server
- A simple web server: Displays a button to open/close
- a door and door status
/
//-----------------------BEGIN Variable setup -------------------------------
String readString = String(30);
//string for fetching data from address
boolean LEDON = false;
//LED status flag
int state;
int val=0;
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 0, 177 };
//Change your IP Address here Server server(80); //Standard HTTP server port
//-----------------------END Variable setup-------------------------------
void setup()
{
pinMode(4, OUTPUT);
Ethernet.begin(mac, ip);
server.begin(); delay(100);
Serial.begin(57600);
//XBee module Baud rate
delay(100);
}
void loop()
{
//---------------Web Server initialization------------------------------
Client client = server.available();
if (client)
{
boolean current_line_is_blank = true;
while (client.connected())
{
if (client.available())
{
char c = client.read();
if (readString.length() < 100)
{
readString += c;
}
///////////Check button status to determine actions to take for submit button///////////////
if(readString.indexOf("IO=1") >0)
{
// If door open request sent;
// send instruction to remote arduino
if (LEDON== false)
{
//Ensure it only send the info once
//led has to be turned ON
LEDON = true;
//Change LED state to print on the page
Serial.print('G');
//Send command to remote Arduino
}
}
if(readString.indexOf("IO=0") >0)
{
//Same as above but not used in
//this application
if (LEDON== true)
{
//led has to be turned OFF
LEDON = false;
Serial.print('K');
}
}
///////////////Finish checking and actions for submit button//////////////////
//------------------Standard web Server Jargon-------------------------------
if (c == 'n' && current_line_is_blank)
{
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: html");
client.println();
client.println("<html>");
client.println("<head>");
client.println("<title>Xboard interface--Door control</title>");
client.println("</head>");
client.println("<body>");
client.print("welcome to DFRobot"); //Print your own message here
client.println("<br />");
client.print("//*************************************");
client.println("<br />");
client.println("<br />");
client.print("//*************************************");
client.println("<br />");
client.println("<br />");
client.print("<form>");
client.print("<input type=radio name=IO value=1 /> Open<br />");
client.print("<input type=submit value=Submit </form><br />");
client.println("</body>");
break;
}
if (c == 'n')
{
// we're starting a new line
current_line_is_blank = true;
}
else if (c != 'r')
{
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
//------------------END Standard web Server Jargon-------------------------------
//-----------------Print door status on web page and auto refresh----------------
if (LEDON)
{
//printing LED status
client.print("<font size='5'>DOOR status: ");
client.println("<font color='green' size='5'>OPEN");
client.println("<META HTTP-EQUIV=REFRESH CONTENT=2;url=http://192.168.0.177/>"); //Autorefresh
//Auto-refresh the site after 2 seconds to reset the door status to closed
}
else{
client.print("<font size='5'>DOOR status: ");
client.println("<font color='grey' size='5'>CLOSED");
}
client.println("<hr />"); client.println("<hr />");
client.println("</body></html>"); //clearing string for next read
readString="";
//-----------------END Print door status on web page and auto refresh----------------
client.stop(); } /Routine to read response from remote Arduino *and light local LED on PIN4 */
if (Serial.available() > 0)
{
val = Serial.read();
if (val == 'H')
{
//These values ('H')can be changed to what ever you want
//just make sure you change them in both the server
//program and the client program
digitalWrite(4, HIGH);
delay (20);
}
if (val == 'L')
{
digitalWrite(4, LOW);
delay (20);
}
}
}
购买 X-Board控制器 兼容Arduino(SKU:DFR0133)