This is an example how to program a mindstorms robot with NQC and XCode

When I purchased a Mac Mini and tried to use NQC within XCode the first time, I found myself a little helpless, because I found no instructions regarding this specific subject. So I decided to release a little sample project here.

+ NQC


This robot is a modified version of the one describe in the great book "The Unofficial Guide to Lego Mindstorms Robots" by Jonathan B. Knudsen & Markus L. Noga.



The original robot has only two frontside bumpers. This modified version has two frontside bumpers along to two frontside lightsensors. So this robot can follow a line and react to obstacles in the way the same time.

The solution to the problem of the missing sensorinput on the rcx is very easy: One bumper and one lightsensor share one input. This input has to be configured to handle a lightsensor. Than it's possible to read the bumper as something very bright in front of the lightsensor.

For example, the value of the lightsensor:

35 : something black
49 : something white
100 : active bumper




But enough about the robot, let's focus on how to program this thing with NQC and XCode:




You have to download nqc (the commandline tool) and use it within a Makefile. Than it's easy to use this Makefile within XCode.

I've built a Sample-Project containing all the things which are needed for a quickstart:

  • NQC
  • NQC Documentation
  • Sample code
  • Makefile
  • Executable Configurations (Prog / Firmware download / Clear RCX)


Download XCode-Project (Power-PC Version only) and copy the folder out of the dmg onto your harddisk: Hank.dmg (1 MB)

Doubleclick "Hank.xcodeproj". Than you're able to select between "Prog", "Firmware" and "Clear RCX" from the selectbox in the Build-View.

The only thing you probably have to do is to change the config of your serial port in the Makefile (see picture above).

After that, you should be able to compile and download the sample program.





Links: