Page 145 - Robots Androids and Animatrons : 12 Incredible Projects You Can Build
P. 145

6.24 Resistive sensor
                                                               for Pot command





















           124









                                  6.25 Schematic for Pot command

                                The value of scale needs to be determined experimentally. To
                                find a good scale value, set the resistive device under measure-
                                ment to its maximum resistance and read the var variable with
                                scale set to 255. Under these conditions, the value held in the
                                var variable will contain a reasonable value for scale.
                                A schematic of a basic circuit is shown in Fig. 6.25. For the resis-
                                tive sensor you can connect a 50K-ohm potentiometer. As the po-
                                tentiometer is varied, one of the LEDs will be lit depending upon
                                the value held in the variable B0. If the resistance value read is
                                above 125, LED 1 will light; if not, LED 2 will light.

                                The program for the PICBASIC compiler is as follows:
                                ‘ PICBASIC Compiler ** reading resistance type sensors **
                                ‘Photoresistor test program
                                                       Team LRN
            Chapter six
   140   141   142   143   144   145   146   147   148   149   150