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

Figure 4.8 LED connected to the analog pin on the Photon board.


             Because we are using the analog pin on the Photon board, we need to use a function
        called analogWrite() to generate the PWM signal and change the brightness of the LED.

        The analog pins on the Photon board are 8-bit values, which means you can write values
        from 0 to 255, as shown in the following:


        int ledPin = A0;



        void setup()  {
          // nothing happens in setup
          pinMode(ledPin, OUTPUT);
        }



        void loop()  {
          // fade in from min to max in increments of 5 points:
   82   83   84   85   86   87   88   89   90   91   92