|
说来也巧,刚才下班后,老觉得手痒,翻出一块ENC28J60模块来仔细端详了一番。这是我以前买的成品控制板的部件,前两周连过一次,没有成功,ping通但http访问不了。总的说,感觉裤有点简陋,连个子网掩码什么都没有配置,心里也没底。加上板子工作电压是3.3V的,没有连成也就没太追究,。
后来,发现了 txmg ENC28J60_for_arduino_v1.0 新裤,当下来了。正好现在就练练手吧。
小心接好后,upload一下,然后打开浏览器,一个熟悉的"Hello world!"展现在面前。激动之情溢于言表。
赶紧把我最想实验的项目搞定——Flash连接Arduino!
做Flash轻车熟路,当然我的技术也很陈旧,从Flash4学过来的,一直学到MX就挂科了,然后几年没动过。正是因为这份感情因素,
我还是习惯称为Macromedia Flash,而不情愿在前面冠以Adobe...
做好flash后,一次调通极为顺利。更改一下电脑的全局设置,就可以很方便的从本地连接网络了。
又锦上添花的拷入手机里,通过WIFI也能工作了。。。看来以后有的玩儿了。
代码,在实例基础上改的。 - // A simple web server control with Macromedia Flash by Thomas 2012.4.11
- #include "etherShield.h"
- #include "ETHER_28J60.h"
- int outputPin = 6;
- static uint8_t mac[6] = {0x54, 0x55, 0x58, 0x10, 0x00, 0x24}; // this just needs to be unique for your network,
- // so unless you have more than one of these boards
- // connected, you should be fine with this value.
-
- static uint8_t ip[4] = {192, 168, 1, 15}; // the IP address for your board. Check your home hub
- // to find an IP address not in use and pick that
- // this or 10.0.0.15 are likely formats for an address
- // that will work.
- static uint16_t port = 80; // Use port 80 - the standard for HTTP
- ETHER_28J60 e;
- void setup()
- {
- e.setup(mac, ip, port);
- pinMode(outputPin, OUTPUT);
- }
- void loop()
- {
- char* params;
- if (params = e.serviceRequest())
- {
- e.print("A0read=");
- e.print(analogRead(1));//print A0 data
- if (strcmp(params, "?cmd=on") == 0)
- {
- digitalWrite(outputPin, HIGH);
- e.print("&ButtonStatus=1"); //print buttonStatus data
- }
- else if (strcmp(params, "?cmd=off") == 0)
- {
- digitalWrite(outputPin, LOW);
- e.print("&ButtonStatus=0");//print buttonStatus data
- }
- e.respond();
- }
- }
复制代码
很萌的flash界面
运行flash联网需要更改flash所在文件夹的安全设置,按任意按钮后,会弹出设置选项。
例如,把flash拷入d:\documents\arduino目录,然后运行flashplay打开,然后随便点击一个按钮(此时需要联网)
flashplayer会弹出设置。
选择目录
允许
选择
允许所选文件夹中的flash文件联网
运行效果。
手机使用也很简单。直接自带浏览器输入网址就可以,需要再做个界面。前几天想在被窝里关灯的那位同学可以参考。
运行时的视频(经过数天的审核终于通过,感谢4楼同学的提醒)
swf及fla源文件,pde也在。
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有帐号?注册
x
|