I am going to attend Hacker School this summer. While I will fill half of my suitcase with LEGO, I won’t be posting regularly.
With that said, I hope there will be some exciting projects I can share with you. Have a great summer… or winter!
I am going to attend Hacker School this summer. While I will fill half of my suitcase with LEGO, I won’t be posting regularly.
With that said, I hope there will be some exciting projects I can share with you. Have a great summer… or winter!
I’m working on a few things that require a bit more code that what I’ve done so far, but I find it to cumbersome to write so much code using NBC, NXC or NXT-G. Then I found Lejos.
Lejos is a Java Virtual Machine for the NXT, and it replaces the standard firmware. While Java is a marginally nicer language, the major win is in the packages.
Lejos comes with a lot of packages that contain useful code for doing common things, neatly organized by names like lejos.navigation.Navigator or java.util.Map.
The only problem with Java is that it’s verbose. Compare a simple program that prints “Hello world!” written in Ruby, and in Java.
You might wonder why Ruby is suddenly involved. It’s because of Mirah, which is Ruby syntax for Java classes. You could thus run the linked Ruby code, but you are actually using java.lang.System.out.println.
This means that if you need to know how to write something, google for the Ruby solution. If you want to know which classes to use, look for the Java solution. (classes are like hierarchical collections of words, more on that later)
To make this all work with the NXT, you first need to instal Lejos.
To install Mirah, you also need to install jRuby, afterwards you can just run
Stay tuned for for some Mirah code for the NXT. I might also tell you more about classes.
So there you are. This is the result of a day or two of LEGO building, followed by weeks of thinking, sawing and soldering. Lucky for you, you don’t have to go through all that, and can just buy the needed parts.
This cute little bug can walk forwards, backwards and turn around, using 4 pumps on 3 switches. The outer 4 legs can move back and forth, with left and right having an individual pump. The middle legs are connected, and can move up and down.
By tilting the middle leg right, the outer right legs come of the ground, while the middle leg on the left is off the ground, then the outer legs can be repositioned for the next cycle.
There are touch sensors on the middle legs, to detect when they are of the ground.
To build this adorable model, you need your NXT, 4 pneumatic pumps, 1 compressor pump, 3 servo valves and a servo controller.
This is the walking routine in NBC for my custom controller. The concept is the same for the Mindsensors one.
#define tilt 0 #define left 1 #define right 2 #define servoport IN_2
thread main SetSensorLowspeed(servoport) OnFwd(OUT_A, 100)
loop: servo(servoport, left, 150, result) servo(servoport, right, 150, result) servo(servoport, tilt, 100, result) wait 7000
servo(servoport, tilt, 150, result) servo(servoport, left, 100, result) servo(servoport, right, 200, result)
wait 5000
servo(servoport, left, 150, result) servo(servoport, right, 150, result) servo(servoport, tilt, 200, result) wait 7000
servo(servoport, tilt, 150, result) servo(servoport, left, 200, result) servo(servoport, right, 100, result) wait 5000
jmp loop
endt