7
\$\begingroup\$

I have a color sensor from the original lego mindstorms set. I have had a hard time finding any reliable specs on the thing, but I did find somebody who has reverse engineered it quite a bit here. The thing only has two connectors though. I am not very good at circuits, but I would like to hook this up to my arduino and read values from it. Does this appear possible? If so, do you have any idea which pins to use, or what kind of code I need?

\$\endgroup\$

2 Answers 2

8
\$\begingroup\$

Most Lego sensors that i have seen use a bridge recifier so that they do only need to have two wires to operate. Also this allows the sensor to be plugged in at any orientation. The circuit for the light sensor is no different.

Using an Arduino, you would connect one wire to an output port and the other wire to an input. By reading the additional article at the bottom of the page, i would say that you should be able to turn the sensor on at the Arduino output for 1.2ms then off for 0.1ms. While off, read the value of the sensor at this time on the Arduino input.

This article also states that the lego RCX is outputting 8V so as the Arduino will only output 5V, you will need to take multiple values and extrpolate a table of values to determine the reading. The value will correspond to an analogue value of 0 to 127 from a lego sensor.

\$\endgroup\$
1
  • \$\begingroup\$ Interesting. I am trying this: void loop(){ digitalWrite(outPin, HIGH); delay(3); digitalWrite(outPin, LOW); sensorValue = analogRead(inPin); Serial.println(sensorValue); } and all I am receiving is 170, no matter what light it is in. If I unplug it it goes to about 227. There is no change if I adjust the delay time. \$\endgroup\$
    – captncraig
    Commented Jun 12, 2010 at 2:09
3
\$\begingroup\$

As for the hardware, you could look at the schematics of the Lego Mindstorms NXT for reference. It is compatible with these old sensors, which can be connected to pins 1 and 2 of the sensor ports:

  • Go to the support page for the NXT.

  • Get the Hardware Developer Kit (no link due to badly designed web page).

  • Look at the schematics for the main unit in Appendix 1.

  • The pins 1 of the sensor ports are handled by an ATmega48, take a look at ADC_A0 to ADC_D0 for the inputs and I_ONA to I_OND for power control. Sensor port pin 2 is ground.

  • The power control circuit contains an extra PNP transistor for current limitation, that may be overkill for you.

When turned on the sensors are powered by the full battery voltage for most of the time, they are only powered off briefly for doing each measurement (I think the 0.1ms by jme are correct). Standard is to do a measurement every three ms.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.