--some functions
dofile("functions.lua")
lighton1=
lighton2=
lighton3=
lighton4= pin1 =
pin2 =
pin3 =
pin4 =
gpio.mode(pin1,gpio.OUTPUT)
gpio.mode(pin2,gpio.OUTPUT)
gpio.mode(pin3,gpio.OUTPUT)
gpio.mode(pin4,gpio.OUTPUT) --pin1
tmr.alarm(,,,function()
if lighton1== then
lighton1=
gpio.write(pin1,gpio.LOW)
-- 512/1024, 50% duty cycle
else
lighton1=
gpio.write(pin1,gpio.HIGH)
end
end)
--pin2
tmr.alarm(,,,function()
if lighton2== then
lighton2=
gpio.write(pin2,gpio.LOW)
-- 512/1024, 50% duty cycle
else
lighton2=
gpio.write(pin2,gpio.HIGH)
end
end)
--pin3
tmr.alarm(,,,function()
if lighton3== then
lighton3=
gpio.write(pin3,gpio.LOW)
-- 512/1024, 50% duty cycle
else
lighton3=
gpio.write(pin3,gpio.HIGH)
end
end)
--pin4
tmr.alarm(,,,function()
if lighton4== then
lighton4=
gpio.write(pin4,gpio.LOW)
-- 512/1024, 50% duty cycle
else
lighton4=
gpio.write(pin4,gpio.HIGH)
end
end)
dofile("sjson.lua")
--inti.lua
--sjson.lua
name = "lxx"
print("Hello world!")
print(name .. ",nihao!")
--functions.lua
function startup()
if file.open("init.lua") == nil then
print("init.lua deleted or renamed")
else
print("Running")
file.close("init.lua")
-- the actual application is stored in 'application.lua'
-- dofile("application.lua")
end
end -- Define WiFi station event callbacks
wifi_connect_event = function(T)
print("Connection to AP("..T.SSID..") established!")
print("Waiting for IP address...")
if disconnect_ct ~= nil then disconnect_ct = nil end
end wifi_got_ip_event = function(T)
-- Note: Having an IP address does not mean there is internet access!
-- Internet connectivity can be determined with net.dns.resolve().
print("Wifi connection is ready! IP address is: "..T.IP)
print("Startup will resume momentarily, you have 3 seconds to abort.")
print("Waiting...")
tmr.create():alarm(, tmr.ALARM_SINGLE, startup)
end wifi_disconnect_event = function(T)
if T.reason == wifi.eventmon.reason.ASSOC_LEAVE then
--the station has disassociated from a previously connected AP
return
end
-- total_tries: how many times the station will attempt to connect to the AP. Should consider AP reboot duration.
local total_tries =
print("\nWiFi connection to AP("..T.SSID..") has failed!") --There are many possible disconnect reasons, the following iterates through
--the list and returns the string corresponding to the disconnect reason.
for key,val in pairs(wifi.eventmon.reason) do
if val == T.reason then
print("Disconnect reason: "..val.."("..key..")")
break
end
end if disconnect_ct == nil then
disconnect_ct =
else
disconnect_ct = disconnect_ct +
end
if disconnect_ct < total_tries then
print("Retrying connection...(attempt "..(disconnect_ct+).." of "..total_tries..")")
else
wifi.sta.disconnect()
print("Aborting connection to AP!")
disconnect_ct = nil
end
end

最新文章

  1. js对Cookie的读写操作
  2. 完美解决AutoCAD2012,AutoCAD2013本身电脑里有NET4.0或以上版本却装不上的问题
  3. sqlserver同步后在不重新初始化快照的情况下新增表
  4. wordpress 添加自定义菜单到管理面板(wp-admin)
  5. svn使用相关问题:eclipse插件,加锁,解锁,偷锁,更新不了,记住密码
  6. mvc Html.BeginForm 生成 ?Length=
  7. OpenCV 中 IplImage、CvMat、Mat中的type是怎么回事?
  8. Arduino UNO +ESP8266采集数据上传到贝壳网
  9. shell 编程之函数
  10. 初学者易上手的SSH-整合
  11. RabbitMQ消息队列(六):使用主题进行消息分发
  12. 第五周java学习总结
  13. Do-Now—团队冲刺博客一(领航篇)
  14. WebAPI常见的鉴权方法,及其适用范围
  15. Java IO API记录
  16. LOJ2542 随机游走 Min-Max容斥+树上期望DP
  17. C#遍历可变化的集合
  18. 【jquery】fancybox 是一款优秀的 jquery 弹出层展示插件
  19. 各大公司Java面试题超详细总结
  20. Hibernate(二)持久化对象的状态

热门文章

  1. MySQL binlog_format (Mixed,Statement,Row)[转]
  2. C# 使用NLog记录日志入门操作
  3. C++ 匿名namespace的作用以及与static的区别
  4. ios开发版证书与企业证书相关文件申请安装及其使用方法
  5. [转]Core Kubernetes: Jazz Improv over Orchestration
  6. Spark 核心篇-SparkContext
  7. logstash retrying failed action with response code: 429
  8. CentOS 7 安装配置OpenVPN 2.3.12
  9. java框架篇---hibernate之连接池
  10. 【emWin】例程二十四:窗口对象——Header