proyectos:jardin_delicias:tecnologicos:centrifugadora
Diferencias
Muestra las diferencias entre dos versiones de la página.
Próxima revisión | Revisión previaÚltima revisiónAmbos lados, revisión siguiente | ||
proyectos:jardin_delicias:tecnologicos:centrifugadora [2016/05/06 22:20] – creado brolin | proyectos:jardin_delicias:tecnologicos:centrifugadora [2016/05/06 22:50] – [ESP8266] brolin | ||
---|---|---|---|
Línea 6: | Línea 6: | ||
http:// | http:// | ||
+ | |||
===== ESP8266 ===== | ===== ESP8266 ===== | ||
Línea 12: | Línea 13: | ||
https:// | https:// | ||
+ | |||
+ | < | ||
+ | wifi.setmode(wifi.SOFTAP) | ||
+ | |||
+ | cfg={} | ||
+ | cfg.ssid=" | ||
+ | cfg.pwd=" | ||
+ | |||
+ | cfg.ip=" | ||
+ | cfg.netmask=" | ||
+ | cfg.gateway=" | ||
+ | |||
+ | port = 9876 | ||
+ | |||
+ | wifi.ap.setip(cfg) | ||
+ | wifi.ap.config(cfg) | ||
+ | |||
+ | function stringStarts(a, | ||
+ | return string.sub(a, | ||
+ | end | ||
+ | |||
+ | function stringEnds(a, | ||
+ | | ||
+ | end | ||
+ | |||
+ | servo = {} | ||
+ | servo.pin = 4 --this is GPIO2 | ||
+ | servo.value = 1500 | ||
+ | servo.id = " | ||
+ | |||
+ | |||
+ | cmd = "" | ||
+ | |||
+ | gpio.mode(servo.pin, | ||
+ | gpio.write(servo.pin, | ||
+ | |||
+ | tmr.alarm(0, | ||
+ | if servo.value then -- generate pulse | ||
+ | gpio.write(servo.pin, | ||
+ | -- print(" | ||
+ | tmr.delay(servo.value) | ||
+ | gpio.write(servo.pin, | ||
+ | end | ||
+ | end) | ||
+ | | ||
+ | |||
+ | function exeCmd(st) -- example: "servo 1500" | ||
+ | if stringStarts(st, | ||
+ | servo.value = tonumber( string.sub(st, | ||
+ | end | ||
+ | end | ||
+ | |||
+ | |||
+ | function receiveData(conn, | ||
+ | cmd = cmd .. data | ||
+ | |||
+ | local a, b = string.find(cmd, | ||
+ | while a do | ||
+ | exeCmd( string.sub(cmd, | ||
+ | cmd = string.sub(cmd, | ||
+ | a, b = string.find(cmd, | ||
+ | end | ||
+ | end | ||
+ | |||
+ | |||
+ | srv=net.createServer(net.TCP, | ||
+ | srv: | ||
+ | print(" | ||
+ | conn: | ||
+ | |||
+ | conn: | ||
+ | | ||
+ | conn: | ||
+ | print(" | ||
+ | end) | ||
+ | | ||
+ | end) | ||
+ | </ | ||
+ |
proyectos/jardin_delicias/tecnologicos/centrifugadora.txt · Última modificación: 2016/05/07 18:41 por brolin