Page 232 - The Unofficial Guide to Lego Mindstorms Robots
P. 232

221












                                                        Figure 11-4.
                                          A bottom view of the CdS photoresistor sensor

          You can make holes for the sensor leads using a small drill. If you don't have one of these, you can heat a wire with a soldering
          iron and push it through the side of the brick, creating a small hole.

          Although LEGO's light sensor is a powered device, the CdS photoresistor is a passive device. This means that you can't blindly
          configure the photoresistor input as a light sensor input. You should, instead, make sure the sensor is not powered and read the
          raw input values.

          In NQC, for example, you can configure the input as follows:

              SetSensorType (SENSOR_1, SENSOR_TYPE_TOUCH);
              SetSensorMode (SENSOR_1, SENSOR_MODE_RAW);

          You'll have to experiment to find out what kind of values you get for different lighting conditions. Darker lighting will produce
          higher sensor readings, while bright lighting produces lower sensor readings.

          Temperature Sensors

          A simple device called a thermistor can be used to make a temperature sensor. The thermistor has a resistance that changes
          according to the temperature. By measuring the resistance of the thermistor, you can figure out the temperature.

          Thermistors are widely available and cost only a couple of dollars each. Chances are, however, that your device won't have the
          same electrical characteristics as the official temperature sensor. Thus, your temperature readings will be off slightly. If you are
          concerned about correct temperature readings, rather than just sensing increases and decreases in temperature, you may want to
          convert raw sensors readings into temperature values yourself.

          Powered Sensors

          It's a little harder to attach a powered circuit to the RCX. Remember, there are only two wires connecting the RCX to each of
          its sensors. For powered sensors, these wires alternately power the sensor and read its value.
   227   228   229   230   231   232   233   234   235   236   237