Getting a Lua program onto the NXT 1

Posted by Tom Fri, 06 Jun 2008 18:26:06 GMT

In my last post, only yesterday, we’ve seen how to install pbLua onto the LEGO NXT. Now we also want it to do something ofcourse.

Let’s first start with connecting to the pbLua-NXT again (using screen – or a utility if you like) and at the > prompt copy and paste the whole following code:

-- Replace HelloWorld on the next line, with the name of the program you want
fileName = "HelloWorld" 

-- Replace the text between [[ and ]] with your own program.
programText = [[
nxt.DisplayClear()
nxt.DisplayText( "Hello, World!" )
]]

h = nxt.FileCreate( fileName, string.len(programText) )
nxt.FileWrite( h, programText )
nxt.FileClose( h )

This now created a file called HelloWorld onto your NXT. To now also run the program give the following command: nxt.dofile('HelloWorld')

That’s all there is to it, isn’t it easy?

Remember that this procedure is not needed if you just want try the API, remember (if you checked yesterday’s article) that we did nxt.SoundTone() on the console.

Comments

Leave a response

Comments