乐鑫的这个开发板, 可以用LUA来编程, 下面的例子是一个简单的web服务器, 当你用浏览器访问wifi的IP时,后面加一个http://ip/abc123, 这样就可以给wifi模组发命令了.

srv=net.createServer(net.TCP,10)
srv:listen(80,function(conn)
conn:on("receive", function(conn, pl)
cmd=string.sub(pl,6,10)
print(cmd)
if (cmd=="abc12") then
  print("yes")
elseif (cmd=="abc13") then
  print("why")
end
conn:send("Hello, NodeMCU.")
end)
conn:on("sent", function(conn) conn:close() end)
end)

神奇...

内核到底是不是linux呢?

设置wifi为softAP:

wifi.setmode(wifi.SOFTAP)
local cfg={}
cfg.ssid="denis_nodemcu"
cfg.pwd="87654321"
wifi.ap.config(cfg)

设置成station:

print("ShipID["..node.chipid().."] Starting...")

print("WiFi connecting...")
wifi.setmode(wifi.SOFTAP)

--wifi.sta.config("fuckapple","11111111")
wifi.sta.connect()

定时器加IO例子:

led=1
gpio.mode(led, gpio.OUTPUT)

switch=0;
tmr.alarm(1, 1000, 1, function ()
  if(switch==0) then
     gpio.write(led, gpio.HIGH)
     switch=1;
  elseif(switch==1) then
     gpio.write(led, gpio.LOW)
     switch=0;
  end
end
)

停止定时器:

tmr.stop(1)
gpio.write(led, gpio.LOW)

基本两天就玩到这里吧.

最新文章

  1. 【转】解读ASP.NET 5 & MVC6系列(1):ASP.NET 5简介
  2. JDI tutorial (trace example)
  3. Bootstrap入门三:页面排版
  4. CF-358D-Dima and Hares【T^T+*^*】
  5. C++11显式虚函数重载
  6. Objective-C和C++的区别
  7. windows2008无线网卡和.net3.5安装
  8. PIVOT行转列
  9. Ubuntu 环境 TensorFlow (最新版1.4) 源码编译、安装
  10. 大白话Vue源码系列(03):生成AST
  11. VectorDrawable与AnimatedVectorDrawable
  12. I - Interesting Calculator (bfs使用优先队列求步数最小或者花费最小)
  13. Python知识点整理,基础3 - 字典操作
  14. 【基础知识】ActiveMQ基本原理
  15. Effective Modern C++翻译(6)-条款5:auto比显示的类型声明要更好
  16. don't run elasticsearch as root.
  17. VC6配置sqlite数据库
  18. Java类的设计----方法的重写、覆盖
  19. 实用技巧:如何用 CSS 做到完全垂直居中
  20. Fragment、FragmentTabHost以及RadioGroup框架

热门文章

  1. iOS 开发者账号共用发布证书 (Distribution)问题
  2. dede如何实现二级栏目导航的仿制
  3. eigen主页
  4. Vue 模板
  5. UIControl事件
  6. mysql:查询排名
  7. FtpWebRequest FTP异步下载、异步上传文件
  8. Silverlight TabItem选中,未选中样式设置
  9. PostgreSQL Replication之第十一章 使用Skytools(2)
  10. Lintcode: O(1) Check Power of 2