<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>degrunt.org: Category programming</title>
    <link>http://www.degrunt.org/articles/category/programming</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>lego, mindstorms, technics, pneumatic</description>
    <item>
      <title>XPM / XPiXMap and pbLua / NXT</title>
      <description>&lt;p&gt;Well, while I was at it tonight, I found that the text-based interface of pbLua isn&amp;#8217;t very user friendly in comparison to the default &lt;span class="caps"&gt;LEGO NXT&lt;/span&gt; interface with it&amp;#8217;s nice icons. Not that we need icons of course, but they&amp;#8217;re cool. ;)&lt;/p&gt;


	&lt;p&gt;So I wrote a Lua class which can open &lt;a href="http://en.wikipedia.org/wiki/X_PixMap"&gt;&lt;span class="caps"&gt;XPM&lt;/span&gt;&lt;/a&gt; images, which are stored on the FileSystem and show them anywhere on the &lt;span class="caps"&gt;NXT&lt;/span&gt;-screen.&lt;/p&gt;


&lt;span class="caps"&gt;XPM&lt;/span&gt; images are also textbased, very ideal for our purpose, albeit they don&amp;#8217;t have a very small footprint (the below image is 160 bytes, so it&amp;#8217;s also not &lt;span class="caps"&gt;TOO&lt;/span&gt; big):
&lt;pre&gt;
! XPM2
16 7 2 1
* c #ffffff
. c #000000
**..*...........
*.*.*...........
**..*..**.**..**
*.*.*.*.*.*..*.*
**..*..**.*...**
...............*
.............**.
&lt;/pre&gt;

	&lt;p&gt;Luckily MacVim understands this format and allows you to see it:
&lt;img src="http://degrunt.org/files/Picture_1.png" alt="" /&gt;&lt;/p&gt;


	&lt;p&gt;Right now this image is on my &lt;span class="caps"&gt;NXT&lt;/span&gt; display &amp;#8211; inverse though, next is making the parsing a bit more flexible.&lt;/p&gt;


	&lt;p&gt;A good thing is that &lt;a href="http://www.pixelmator.com/"&gt;PixelMator&lt;/a&gt; can convert to &lt;span class="caps"&gt;XPM&lt;/span&gt;, so no manual editing of &lt;span class="caps"&gt;XPM&lt;/span&gt; files ;)&lt;/p&gt;


	&lt;p&gt;Now to see whether we can get the below image to show on the &lt;span class="caps"&gt;NXT&lt;/span&gt; screen (nope no colors):&lt;/p&gt;


	&lt;p&gt;&lt;img src="http://degrunt.org/files/pblua.png" alt="" /&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 07 Jun 2008 01:05:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:0941514d-74aa-4e5d-a5e7-3bd9ebe0a820</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2008/06/07/xpm-xpixmap-and-pblua-nxt</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
    </item>
    <item>
      <title>Getting a Lua program onto the NXT</title>
      <description>&lt;p&gt;In my last post, only yesterday, we&amp;#8217;ve seen how to install pbLua onto the &lt;span class="caps"&gt;LEGO NXT&lt;/span&gt;. Now we also want it to do something ofcourse.&lt;/p&gt;


	&lt;p&gt;Let&amp;#8217;s first start with connecting to the pbLua-NXT again (using screen &amp;#8211; or a utility if you like) and at the &amp;gt; prompt copy and paste the whole following code:&lt;/p&gt;


&lt;pre&gt;
-- 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 )
&lt;/pre&gt;

	&lt;p&gt;This now created a file called &lt;code&gt;HelloWorld&lt;/code&gt; onto your &lt;span class="caps"&gt;NXT&lt;/span&gt;. To now also run the program give the following command: &lt;code&gt;nxt.dofile('HelloWorld')&lt;/code&gt;&lt;/p&gt;


	&lt;p&gt;That&amp;#8217;s all there is to it, isn&amp;#8217;t it easy?&lt;/p&gt;


	&lt;p&gt;Remember that this procedure is not needed if you just want try the &lt;span class="caps"&gt;API&lt;/span&gt;, remember (if you checked yesterday&amp;#8217;s article) that we did &lt;code&gt;nxt.SoundTone()&lt;/code&gt; on the console.&lt;/p&gt;</description>
      <pubDate>Fri, 06 Jun 2008 20:26:06 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:69a85cba-0071-4461-843d-7c18c44ed18f</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2008/06/06/getting-a-lua-program-onto-the-nxt</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
    </item>
    <item>
      <title>Lua on LEGO Mindstorm NXT</title>
      <description>&lt;p&gt;Wow! It&amp;#8217;s been a long time since I wrote here, but in the mean time cool things have happened. Firstly there&amp;#8217;s &lt;a href="http://www.hempeldesigngroup.com/lego/pbLua/"&gt;pbLua&lt;/a&gt;, secondly I bought myself a Lua book.&lt;/p&gt;


	&lt;p&gt;So, how now do you go about to install pbLua on your &lt;span class="caps"&gt;NXT&lt;/span&gt;? If you&amp;#8217;re using Windows, there&amp;#8217;s not really an issue, because that&amp;#8217;s all explained on the homepage. I&amp;#8217;m using a Mac, so here it is.&lt;/p&gt;


	&lt;h1&gt;Setup&lt;/h1&gt;


	&lt;p&gt;1) First download pbLua, I&amp;#8217;ve got a &amp;#8216;nxt-lua-beta-15b&amp;#8217; folder on my Desktop.&lt;/p&gt;


	&lt;p&gt;2) Start up &lt;span class="caps"&gt;LEGO&lt;/span&gt;&amp;#8217;s &lt;span class="caps"&gt;MINDSTORMS NXT&lt;/span&gt;&lt;/p&gt;


	&lt;p&gt;3) Use the Tools menu and use the &amp;#8220;Update &lt;span class="caps"&gt;NXT&lt;/span&gt; Firmware&amp;#8230;&amp;#8221; option, click &amp;#8220;Browse&amp;#8221; and navigate using the browser to the folder  &amp;#8216;nxt-lua-beta-15b&amp;#8217; on your Desktop. The window should show &amp;#8220;nxt-lua&amp;#8221; as &amp;#8220;Available Firmware Files&amp;#8221;.&lt;/p&gt;


	&lt;p&gt;4) Now connect your &lt;span class="caps"&gt;NXT&lt;/span&gt;, click &amp;#8220;Download&amp;#8221; and wait &amp;#8230;.&lt;/p&gt;


	&lt;p&gt;5) If everything is correct, your &lt;span class="caps"&gt;NXT&lt;/span&gt; screen should show &amp;#8220;pbLua Beta 15b&amp;#8221;, the 15b depends on the version you downloaded.&lt;/p&gt;


	&lt;h1&gt;Okay now what?&lt;/h1&gt;


	&lt;p&gt;Now you&amp;#8217;ve got a Lua-enabled &lt;span class="caps"&gt;NXT&lt;/span&gt;, but it&amp;#8217;s not very clear how to continue further. Luckily it says &lt;a href="http://www.hempeldesigngroup.com/lego/pbLua/pbLuaStartupDisplay.html"&gt;somewhere on the homepage&lt;/a&gt; that there&amp;#8217;s a &lt;span class="caps"&gt;USB&lt;/span&gt; Console as well as a BT (BlueTooth) Console. 
Let&amp;#8217;s start with the &lt;span class="caps"&gt;USB&lt;/span&gt; Console.&lt;/p&gt;


	&lt;p&gt;1) Fire up Terminal.app&lt;/p&gt;


	&lt;p&gt;2) Do an &lt;code&gt;ls /dev/tty.usb*&lt;/code&gt;, in my case this shows a &lt;code&gt;/dev/tty.usbmodem1a21&lt;/code&gt;, but your results may vary.&lt;/p&gt;


3) Then do a &lt;code&gt;screen /dev/tty.usbmodem1a21&lt;/code&gt;, this should refresh your screen and show you:
&lt;pre&gt;
pbLua Beta 15b
&amp;gt; 
&lt;/pre&gt;

	&lt;p&gt;You&amp;#8217;re now in a Lua interpreter, type &lt;code&gt;print("Hello World!")&lt;/code&gt;, just for the kicks of it!&lt;/p&gt;


	&lt;p&gt;Basically you can now use the &lt;a href="http://www.hempeldesigngroup.com/lego/pbLua/nxtFunctionDefs.html"&gt;pbLua &lt;span class="caps"&gt;API&lt;/span&gt;&lt;/a&gt;, to do anything you want, try &lt;code&gt;nxt.SoundTone()&lt;/code&gt; for example, woohoo isn&amp;#8217;t that great?!&lt;/p&gt;


	&lt;p&gt;4) To quit the Console type Ctrl-a Ctrl-\.&lt;/p&gt;


	&lt;h1&gt;Enabling Bluetooth&lt;/h1&gt;


	&lt;p&gt;1) Basically you go about as you would connect any other Bluetooth device to your Mac, just select &amp;#8220;Any Device&amp;#8221;, find the &lt;span class="caps"&gt;NXT&lt;/span&gt; in the list of Devices and have the &amp;#8220;Use a specific passkey&amp;#8221; option selected for the Passkey Options.&lt;/p&gt;


	&lt;p&gt;2) During &amp;#8220;Gathering information about your device&amp;#8221; and while it&amp;#8217;s connecting, Mac &lt;span class="caps"&gt;OSX&lt;/span&gt; will ask you for a passkey, think of something, then go to your &lt;span class="caps"&gt;USB&lt;/span&gt; console and use the Lua function &lt;code&gt;nxt.BtSetPIN('something')&lt;/code&gt; (on your &lt;span class="caps"&gt;USB&lt;/span&gt; console) to confirm the bluetooth-passkey from your &lt;span class="caps"&gt;NXT&lt;/span&gt; end.
At some point Mac &lt;span class="caps"&gt;OSX&lt;/span&gt; will say &amp;#8220;Connected&amp;#8221;. Remember the device name!&lt;/p&gt;


	&lt;h1&gt;Bluetooth Console&lt;/h1&gt;


	&lt;p&gt;1) Reboot your &lt;span class="caps"&gt;NXT&lt;/span&gt; (by holding the grey button for some time) and start it again by clicking the orange button. Then you should see something like:&lt;/p&gt;


&lt;pre class="nxtDisplay"&gt;
USB Console
BT Console
. 
. 
. 
. 
. 
. 
00000 Button:0
&lt;/pre&gt;

	&lt;p&gt;Then use the dark grey button, to highlight BT Console, next use the arrow buttons to find the device name of your computer (which in my case is &amp;#8216;galactica&amp;#8217;).&lt;/p&gt;


&lt;pre class="nxtDisplay"&gt;
USB Console
BT Console
. 
.
galactica
AD:000000000000
CL:000000
ST:00 Idx: 00 
00000 Button:0
&lt;/pre&gt;

	&lt;p&gt;Once you&amp;#8217;ve got this selected, the screen should show:&lt;/p&gt;


&lt;pre class="nxtDisplay"&gt;
Wait for connect
Active: 00
Update:  0 
.
.
.
.
.
.
&lt;/pre&gt;

	&lt;p&gt;2) Fire up Terminal.app&lt;/p&gt;


	&lt;p&gt;3) Do an &lt;code&gt;ls /dev/cu.&amp;lt;bluetooth-device-name&amp;gt;*&lt;/code&gt;, in my case my &lt;span class="caps"&gt;NXT&lt;/span&gt; is called &amp;#8220;r2d2&amp;#8221; (yup!). So I did a &lt;code&gt;ls /dev/cu.r2d2*&lt;/code&gt;, this shows a &lt;code&gt;/dev/cu.r2d2-DevB-1&lt;/code&gt;, but your results may vary, depending on your device name.&lt;/p&gt;


3) Then do a &lt;code&gt;screen /dev/cu.r2d2-DevB-1&lt;/code&gt; (or whatever you found at step 2), this should refresh your screen and show you:
&lt;pre&gt;
pbLua Beta 15b
&amp;gt; 
&lt;/pre&gt;

	&lt;p&gt;Woohoo, wireless pbLua!!&lt;/p&gt;


	&lt;p&gt;More to follow, later, keep you posted &amp;#8211; check back!&lt;/p&gt;</description>
      <pubDate>Fri, 06 Jun 2008 00:39:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:00ba9a38-6c38-4f85-aa71-48953c2ec00a</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2008/06/06/lua-on-lego-mindstorm-nxt</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
      <category>hacking</category>
    </item>
    <item>
      <title>Ruby &amp;amp; Mindstorms NXT</title>
      <description>&lt;p&gt;Using &lt;a href="http://www.ruby-lang.org/en/"&gt;Ruby&lt;/a&gt; with your Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt; is easy using &lt;a href="http://ruby-nxt.rubyforge.org/"&gt;RubyNXT&lt;/a&gt;. But it still requires a bluetooth connection or &lt;span class="caps"&gt;USB&lt;/span&gt; connection.&lt;/p&gt;


	&lt;p&gt;How cool would it be if it was possible to write a Ruby program, upload it (in sourcecode) to your &lt;span class="caps"&gt;NXT&lt;/span&gt; brick and have a Ruby interpreter firmware running on the &lt;span class="caps"&gt;NXT&lt;/span&gt;? It wouldn&amp;#8217;t be needed to port the whole &lt;a href="http://www.ruby-doc.org/stdlib/"&gt;Ruby Standard Library&lt;/a&gt;, it wouldn&amp;#8217;t even be needed to convert the whole &lt;a href="http://www.ruby-doc.org/core/"&gt;Ruby Core Library&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;So what would be needed to get this to work? Cross-compilation of Ruby to &lt;span class="caps"&gt;ARM&lt;/span&gt;, someone already &lt;a href="http://www.caliban.org/ruby/ruby-zaurus.shtml"&gt;ported Ruby to his Zaurus&lt;/a&gt;. A new firmare is needed.&lt;/p&gt;


	&lt;p&gt;Maybe better yet is the use of a Ruby VM like &lt;a href="http://www.atdot.net/yarv/"&gt;&lt;span class="caps"&gt;YARV&lt;/span&gt;&lt;/a&gt; and get that to run on the Mindstorms brick. Still, that needs to be cross compiled and a new firmware is needed.&lt;/p&gt;


	&lt;p&gt;Ruby is a fully object oriented programming language and is fairly easy to learn, even easier to use. More and more programmers learn Ruby.&lt;/p&gt;</description>
      <pubDate>Sat, 14 Oct 2006 11:29:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:cef68423-5a6c-4e37-99a4-7a2179c6a006</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2006/10/14/ruby-mindstorms-nxt</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
      <category>hacking</category>
    </item>
    <item>
      <title>NXT Linux</title>
      <description>&lt;p&gt;Just a short article on thoughts for a Linux for Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt;. How hard would it be to do something similar as &lt;a href="http://www.ipodlinux.org/Main_Page"&gt;iPod Linux&lt;/a&gt; with the &lt;span class="caps"&gt;NXT&lt;/span&gt; brick, ie a &lt;span class="caps"&gt;LEGO&lt;/span&gt; Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt; running &lt;a href="http://www.uclinux.org/"&gt;&amp;mu;CLinux&lt;/a&gt;? The Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt; is based on the &lt;a href="http://www.atmel.com/dyn/products/product_card.asp?part_id=3524"&gt;Atmel &lt;span class="caps"&gt;AT91SAM7S256&lt;/span&gt;&lt;/a&gt;, it&amp;#8217;s a microcontroller. &lt;a href="http://www.jstuber.net/lego/nxt-programming/index.html"&gt;Jurgen Stuber&lt;/a&gt; already hints at programming for the Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt; using a cross-compiler.&lt;/p&gt;


	&lt;p&gt;As far as I understand the latest generation iPod is also based on &lt;a href="http://www.portalplayer.com/products/documents/5020_Brief_0108_Public.pdf"&gt;&lt;span class="caps"&gt;ARM7&lt;/span&gt; processors&lt;/a&gt;.&lt;/p&gt;


	&lt;p&gt;With the help of something like &lt;a href="http://sdcc.sourceforge.net/"&gt;&lt;span class="caps"&gt;SDCC&lt;/span&gt;&lt;/a&gt; it should be possible to then build C programs (or the like) for the &lt;span class="caps"&gt;NXT&lt;/span&gt; brick.&lt;/p&gt;


	&lt;p&gt;I guess it&amp;#8217;s just time which will tell.&lt;/p&gt;</description>
      <pubDate>Thu, 12 Oct 2006 11:15:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:f3825b54-c5c2-4b68-991b-6e304c98ba54</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2006/10/12/nxt-linux</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
    </item>
    <item>
      <title>NBC: How to read Mindstorms touch sensor</title>
      <description>&lt;p&gt;Here a small program to read the touch sensor value. Be sure to connect the touch sensor to port 1.&lt;/p&gt;


&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_nbc "&gt;&lt;span class="keyword"&gt;#include&lt;/span&gt; &amp;quot;NXTDefs.h&amp;quot;

&lt;span class="keyword"&gt;dseg&lt;/span&gt; &lt;span class="keyword"&gt;segment&lt;/span&gt; 
  dtArgs TDrawText 
&lt;span class="keyword"&gt;dseg&lt;/span&gt; &lt;span class="keyword"&gt;ends&lt;/span&gt; 

&lt;span class="keyword"&gt;thread&lt;/span&gt; main

    &lt;span class="keyword"&gt;dseg&lt;/span&gt; &lt;span class="keyword"&gt;segment&lt;/span&gt;
        sensorValue byte
        sensorPort byte
    &lt;span class="keyword"&gt;dseg&lt;/span&gt; &lt;span class="keyword"&gt;ends&lt;/span&gt;

    setin IN_TYPE_SWITCH, IN_1, Type
    setin IN_MODE_RAW, IN_1, InputMode

Endless:

    getin sensorValue, IN_1, RawValue

    &lt;span class="keyword"&gt;set&lt;/span&gt; dtArgs.Location.X, 1
    &lt;span class="keyword"&gt;set&lt;/span&gt; dtArgs.Location.Y, 1

    &lt;span class="comment"&gt;// Clear entire screen&lt;/span&gt;
    &lt;span class="keyword"&gt;set&lt;/span&gt; dtArgs.Options, 1 

    &lt;span class="comment"&gt;// Convert from number to string&lt;/span&gt;
    numtostr dtArgs.Text, sensorValue

    &lt;span class="keyword"&gt;syscall&lt;/span&gt; DrawText, dtArgs

    &lt;span class="keyword"&gt;jmp&lt;/span&gt; Endless

&lt;span class="keyword"&gt;endt&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</description>
      <pubDate>Wed, 04 Oct 2006 21:23:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:4586f968-f083-40f4-883d-203371eee315</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2006/10/04/nbc-how-to-read-mindstorms-touch-sensor</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
    </item>
    <item>
      <title>Getting started with NBC on Apple OSX</title>
      <description>&lt;p&gt;&lt;span class="caps"&gt;NBC&lt;/span&gt; means NeXT Byte Code and is an assembler like programming language for the &lt;span class="caps"&gt;LEGO&lt;/span&gt; Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt; programmable brick. It uses the default &lt;span class="caps"&gt;LEGO&lt;/span&gt; firmware. What follows is a tutorial on how to start programming using your Mac and &lt;span class="caps"&gt;NBC&lt;/span&gt;.&lt;/p&gt;&lt;h2&gt;Writing and compiling the code&lt;/h2&gt;
First download &lt;span class="caps"&gt;NBC&lt;/span&gt; (I&amp;#8217;ve used version 1.0.1 b8) from &lt;a href="http://bricxcc.sourceforge.net/nbc/"&gt;the &lt;span class="caps"&gt;NBC&lt;/span&gt; homepage&lt;/a&gt;. This will usually download onto your desktop. The editor I use is &lt;a href="http://macromates.com/"&gt;TextMate&lt;/a&gt;, it&amp;#8217;s not expensive and is very usable. Later I will publish a TextMate Bundle for &lt;span class="caps"&gt;NBC&lt;/span&gt;, so that it&amp;#8217;ll become easier to start programming. Now type or cut-and-paste the following code (which I &lt;i&gt;stole&lt;/i&gt; from &lt;a href="http://www.bnxt.com/blog/2006/08/getting-started-with-nxt-byte-code-nbc.html"&gt;here&lt;/a&gt;) in TextMate and save the file as &lt;b&gt;helloworld.nbc&lt;/b&gt;:

&lt;div class="typocode"&gt;&lt;pre&gt;&lt;code class="typocode_nbc "&gt;&lt;span class="keyword"&gt;#include&lt;/span&gt; &amp;quot;NXTDefs.h&amp;quot;
&lt;span class="comment"&gt;// Always include the above&lt;/span&gt;

&lt;span class="comment"&gt;// Segments declare variables or types&lt;/span&gt;
&lt;span class="keyword"&gt;dseg&lt;/span&gt; &lt;span class="keyword"&gt;segment&lt;/span&gt; 
  &lt;span class="comment"&gt;// Variables are always global.&lt;/span&gt;
  &lt;span class="comment"&gt;// Define variable dtArgs of type TDrawText&lt;/span&gt;
  dtArgs TDrawText &lt;span class="comment"&gt;/* see Syscall DrawText docs */&lt;/span&gt;
&lt;span class="keyword"&gt;dseg&lt;/span&gt; &lt;span class="keyword"&gt;ends&lt;/span&gt; 

&lt;span class="comment"&gt;// Code is organized in threads &lt;/span&gt;
&lt;span class="keyword"&gt;thread&lt;/span&gt; main
  &lt;span class="comment"&gt;// Set is to store scalar constants&lt;/span&gt;
  &lt;span class="comment"&gt;// For instance, set X location to 1&lt;/span&gt;
  &lt;span class="comment"&gt;// X is a member of the TDrawText struct&lt;/span&gt;
  &lt;span class="keyword"&gt;set&lt;/span&gt; dtArgs.Location.X, 1
  &lt;span class="keyword"&gt;set&lt;/span&gt; dtArgs.Location.Y, 1
  &lt;span class="keyword"&gt;set&lt;/span&gt; dtArgs.Options, 1 &lt;span class="comment"&gt;/* erase previous text */&lt;/span&gt;
  &lt;span class="comment"&gt;// Mov is to copy more complex data&lt;/span&gt;
  &lt;span class="keyword"&gt;mov&lt;/span&gt; dtArgs.Text, 'Hello World'

  &lt;span class="comment"&gt;// Write to the screen &lt;/span&gt;
  &lt;span class="comment"&gt;// by calling the Lego firmware&lt;/span&gt;
  &lt;span class="keyword"&gt;syscall&lt;/span&gt; DrawText, dtArgs

  &lt;span class="comment"&gt;// Wait forever so the user sees the screen&lt;/span&gt;
Endless:
  &lt;span class="keyword"&gt;jmp&lt;/span&gt; Endless
&lt;span class="keyword"&gt;endt&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;

	&lt;p&gt;Okay now you need to start Terminal.app and run nbc:&lt;br /&gt;
&lt;img src="/media/nbc_terminal.png"/&gt;&lt;br /&gt;
Make sure the extension of your sourcecode is &lt;b&gt;.nbc&lt;/b&gt;, the extension of the output file is &lt;b&gt;.rxe&lt;/b&gt; and the command you type is: &lt;code&gt;./nbc helloworld.nbc -O=helloworld.rxe&lt;/code&gt;. For more command-line options type &lt;code&gt;./nbc -help&lt;/code&gt;.
&lt;h2&gt;Putting it on the brick&lt;/h2&gt;
Currently the Mac version of the &lt;span class="caps"&gt;NBC&lt;/span&gt; program is not capable of &lt;i&gt;downloading&lt;/i&gt; your program to the &lt;span class="caps"&gt;NXT&lt;/span&gt; brick, like the Windows version does, so we&amp;#8217;ll need to use the Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt; software which came with your kit:&lt;br /&gt;
&lt;img src="/media/mindstorms_app.png" /&gt;
&lt;p /&gt;
First start the software and start you&amp;#8217;re brick (press the orange button). Now we need to &lt;i&gt;download&lt;/i&gt; to you&amp;#8217;re brick, the simplest way of achieving this I think is by pressing the &lt;i&gt;New program GO button&lt;/i&gt;:&lt;br /&gt;
&lt;img src="/media/mindstorms_go.png" /&gt;
&lt;p /&gt;
Now click the &lt;i&gt;&lt;span class="caps"&gt;NXT&lt;/span&gt; Window&lt;/i&gt; button and open the &lt;i&gt;Memory&lt;/i&gt; tab:&lt;br /&gt;
&lt;img src="/media/nxt_window.png" /&gt;&lt;br /&gt;
&lt;img src="/media/nxt_memory_tab.png" /&gt;
&lt;p /&gt;
Click the &lt;i&gt;Download&lt;/i&gt; button and find your &lt;b&gt;helloworld.rxe&lt;/b&gt; application:&lt;br /&gt;
&lt;img src="/media/mindstorms_desktop.png" /&gt;&lt;p /&gt;
Click the &lt;i&gt;Ok&lt;/i&gt; button and &amp;#8230; that&amp;#8217;s it! Now start &lt;b&gt;helloworld&lt;/b&gt; from your brick! Quit the Mindstorms &lt;span class="caps"&gt;NXT&lt;/span&gt; application and don&amp;#8217;t save the program (as there isn&amp;#8217;t any programming done in the &lt;span class="caps"&gt;LEGO&lt;/span&gt; Mindstorms application). Do save your &lt;b&gt;helloworld.nbc&lt;/b&gt; program of course!
&lt;h2&gt;Afterthoughts and future&lt;/h2&gt;
Some afterthoughts and something on the future on &lt;span class="caps"&gt;NXT&lt;/span&gt; and Mac:
&lt;ul&gt;
&lt;li&gt;In the near future &lt;span class="caps"&gt;NBC&lt;/span&gt; on Mac &lt;span class="caps"&gt;OSX&lt;/span&gt; will very likely support auto-downloading to your brick, which simplifies things drastically.&lt;/li&gt;
&lt;li&gt;TextMate supports Bundles, which are helpers to simplify programming for you. In the near future I will create such a TextMate Bundle and publish it on this site&lt;/li&gt;
&lt;li&gt;This site is built using &lt;a href="http://typosphere.org/"&gt;Typo&lt;/a&gt; and uses &lt;span class="caps"&gt;NBC&lt;/span&gt; code syntax highlighting using the default plugin of Typo and a &lt;span class="caps"&gt;NBC&lt;/span&gt; specific class to do the highlighting. I will publish this later.&lt;/li&gt;
&lt;/ul&gt;
For any hints, suggestions and or tips mail me at: tom &lt;i&gt;at&lt;/i&gt; degrunt &lt;i&gt;dot&lt;/i&gt; nl&lt;/p&gt;</description>
      <pubDate>Sat, 30 Sep 2006 23:20:00 +0200</pubDate>
      <guid isPermaLink="false">urn:uuid:34aaa79d-10d5-431c-bc48-f6b781f8bf64</guid>
      <author>Tom</author>
      <link>http://www.degrunt.org/articles/2006/09/30/getting-started-with-nbc-on-apple-osx</link>
      <category>mindstorms</category>
      <category>nxt</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
