When I left my last job, my friends gave me a big farewell gift : LegoNxt. It’s an amazing gift, i’ve always loved lego. And when I was a boy the toy I love the most is always lego. And LegoNxt is even more awesome for me now as I become a programmer, combining program and lego is the sweetest dream for me.
So in order to return my thanks to my friends, I try to come up with a project using LegoNxt, I did have an idea a year ago and had a working prototype, but the result is not satisfying enough, however I really enjoy the process of building robots and control them through codes.
This time i had a simple idea : I want to record myself building another lego set, but i don’t want the camera stay still. I want it to move slowly from one side to another. So i begin to build this little lego car and control it by processing.
I found this NXTComm library and it’s very useful. It allows you to control your legoNxt via bluetooth, and it’s very easy to use. To setup you just need to do this :
_nxt = new LegoNXT(this, Serial.list());
As I recalled the only tricky thing is to find the right bluetooth port you are using which is the  means, you might need to test a little bit to find out which one is exactly the one you need.
After this you are ready to go, the library is very compact, you have all the api you need including both the sensors and motors. I didn’t need any sensor on this project but i did a quick test with ultrasonic sensor to get the distance from the sensor to the object, the result is very responsive, makes me want to do more with it. As for the motor it’s really simple to control as well :
_nxt.motorForwardLimit(LegoNXT.MOTOR_A, maxForce, 150); // moving with limit _nxt.motorForward(LegoNXT.MOTOR_A, maxForce); // just keep moving, need to call _nxt.motorStop manually.
So this library covers pretty much all the controls you need, the only thing left is to build the actual robot. It’s so much fun to build it e.g. how to place the gears to control the speed so it won’t go too fast, some old knowledge from high school/university i thought i’ll never need them become very handy now
I’ve always worked on the coding part and didn’t get involved with the hardware part too much. But now i’m really interested in building robots, hope I’ll have more time to dig into this field and I’d like to learn arduino as well !
And last, a short video of the recording result using this little robot: