Page 199 - Programming the Photon Getting Started With the Internet of Things
P. 199

pin number, instead of typing the pin number every time, it is easier to put “led” if you
        have an LED connected to that pin.




        pinMode


        This sets the direction of a pin to either an output or an input. This function is always
        included in setup().




        Syntax


                   pinMode(pin, mode);




        Parameters

        pin

             The pin number.

        mode

             Either an INPUT or an OUTPUT (case sensitive).




        Example


                   pinMode(D0, OUTPUT);

        This  sets  digital  pin  0  to  an  output  pin,  which  can  be  controlled  using  the  function

        digitalWrite.



        servo.attach



        This assigns a servo object to a particular pin on the Photon board.



        Syntax


                   myServo.attach(pin);




        Parameters

        pin

             The pin number.

        myServo
   194   195   196   197   198   199   200   201   202   203   204