It’s been a little while since my last article about adding peripherals to the NXT, but not due to the lack of experimenting and programming, let me tell you. In my quest to tame the Maxim MAX127, I ran into a few annoying bugs in RobotC. The first one involved not being able to use structs of bytes to send I2C commands to the sensor and the other involving automatic conversion of unsigned bytes to signed integers. RobotC does not really support unsigned variables, with the exception of bytes and chars. When you use an unsigned variable inadvertently you’re greeted with a nice warning:
Warning*:ROBOTC only supports ‘unsigned’ qualifier on ‘byte’ / ‘char’ sized variables. Ignored for other type.
I figured out a work-around for both bugs, so all is well now.
To the right you can see the fruits of my labour; a breadboard with a MAX127, a pot meter and a bunch of other components, as described in the table below.
|R1, R2||82 KOhm|
|R3, R4||1 KOhm|
|R5||1 KOhm pot|
|C3, C4, C5||0.1 uF|
|D1||Red LED 10mA|
The LED is there merely as a status LED so you can see when power has been applied to the board. The connector is a home made one, as described in this article.
The schematic for this can be seen on the left. It would be very trivial to add more pot meters to this and tweak the program to make use of them. Of course, pot meters are not the only thing that can be read by an ADC such as the MAX127. You could connect IR photo-transistors, thermistors, LDRs, you name it! In a future article I will be hooking up various other sensors and use them as inputs for a robot. Stay tuned for more information.
The source code for this article can be found here: LINK.