Microchip prodces a wide range of microcontrollers that can be used to produce intelligent homebrew sensors and actuators for the NXT. They sell a PICkit 2 Starter Kit that is a $50 way to get started. It comes with a little prototype board called the Low Pin Count demo or LPC. That LPC has some LEDs, a potentiometer, and a small prototype area.
I programmed the 16F690 that comes with the LPC to do the I2C slave needed to interface with the NXT. The program works well with the NXT-G I2CWrite and I2CRead blocks that you can inport to the Mindstorms software. The program gives you 7 registers to read and write to. Inside the PIC you can do whatever you want with the registers. For example, I write the value of register 1 to the LEDs, put the value of the A to D converter in register 2, and read two switches I added into register 3.
Here is a short video of it working:
Here is a little NXT-G program to exercise the PIC program. It writes the loop value to register 1 and then reads it back. Then it reads register 3 to see which button is being pressed. Finally it reads register 2, converts the value into a frequency, and produces a tone.
Pin RB6 connects to the NXT yellow wire, RB4 is blue, Ground is both the black and red. Only connect the green wire to Vdd when you want to run the LPC standalone without the PIC 2 programmer powering it. You also need to pull RB6 and RB4 to Vdd through 82K resistors. When you are debugging you have to remember to click the "set MCLR to Vdd" button in MPLAB to allow the program to run on the LPC.
Here are all the PIC files you need to build the program.