This is the code for a Lego Mindstorms NXT 2.0 scorpion.
Behaviour
4.) open your lego mindstorms nxt 2.0 programming interface 5.)create a new program 6.) click on the NXT window in the bottom right corner 7.)select your nxt it should be connected to your computer 8.)select the memory tab in the nxt window 9.)click download.
The code is very simple. I was only interested in the sting mechanismso this is the only behaviour this program implements (it has nolegs).
The UltraSound sensor should be plugged into input 1 and the sting'smotor into output A. At the moment, it assumes that the sting startsin the closed position (I may add a setup step that pulls the sting infirst at some point).
Construction
My scorpion is based on a design found onactive-robots. I'veditched much of the design, in particular the legs. Unfortunately,these instructions require pieces that don't appear to come in thedefault NXT 2.0 kit. My kit only contains two 15-length pieces, whichis less than the sting mechanism requires. I got around this byscaling down the size of the sting by replacing 15-length pieces with13, 13 with 11 and so on.
Usage
You'll need to build a suitable machine out of the Mindstorms kit. Youcan then connect it to your computer using a USB cable.
If you haven't done so already, get set up with the following steps:
Then, with the
nbc
command set up and on your path, run thefollowing from the scorpion
directory.This will compile the program and send it to the connected NXT device.