viewtopic.php?id=7491 (Ignore the post by kaeza as it's a red herring... appreciate the humour though :-D )
I have followed through the chattybricks tutorial that Jeija released on github as minetest-modding-tutorial so some of that code is remaining for debugging purposes.
Hate to say it but I'm not comprehending how to do this. Ignore the Arduino side as that it basically done. Send the string "LED1:1" and the light turns on, LED1:0 will turn it off.. easy.
As I believe that I can't use an endless loop in a minetest lua script, I figure that the inbound data could be read using a register_globalstep() function with minimal processing. The outbound serial data is sent on events such as a player hitting a block. Current code below, I'm not sure how much I of the TODO code loop I need to include.
Code: Select all
local r = p.poll(set, -1) for fd, d in pairs(set) do if d.revents and d.revents.IN then if fd == 0 then local d, err = p.read(0, 1024) if not d then exit(err) end if d == string.char(3) then exit("Bye") end local ok, err = p.write(fds, d) if not ok then exit(err) end end if fd == fds then local d, err = p.read(fds, 1024) if not d then exit(err) end local ok, err = p.write(1, d) if not ok then exit(err) end end end end
More than happy to add a page to document this into the wiki when I get this example complete. Might fire someone's imagination...