2 Replies Latest reply on Mar 12, 2014 1:12 PM by JPMontero_Intel

    Galileo analogWrite followed by digitalWrite on Pin 11 operates differently than Arduino Uno

    ttrickel

      When using an Intel Galileo board and Arduino 1.5.3 an analogWrite(11, 0) followed by a digitalWrite(11, HIGH) does not result in a high on pin 11.

       

      I stumbled across this when I wired up the SparkFun Inventor's Kit circuit #3 RGB LED. The program starts by blinking the LED Red, Green, Blue and a few more "solid" colors via digitalWrite. The program then moves onto using analogWrites to display a range of colors. The program loops back to the beginning where it should blink Red, Green, Blue but the blue never comes on. I traced this down to the curiosity mentioned above.

       

      I isolated the program to the following program which should blink the LED Green followed by blinking the LED Blue. The blue blink never happens.

       

      const int RED_PIN = 9;

      const int GREEN_PIN = 10;

      const int BLUE_PIN = 11;

       

        analogWrite(RED_PIN, 0);

        analogWrite(BLUE_PIN, 0);

        analogWrite(GREEN_PIN, 255);

       

       

        delay(1000);

       

        digitalWrite(RED_PIN, LOW);

        digitalWrite(GREEN_PIN, LOW);

        digitalWrite(BLUE_PIN, HIGH);

       

       

        delay(1000);

       

      Is there something I am missing or is this an undocumented feature?

        • 1. Re: Galileo analogWrite followed by digitalWrite on Pin 11 operates differently than Arduino Uno
          Intel_Jesus

          Hi ttrickel,

           

          Using the code provided by Sparkfun SIK Guide Circuit #3 RGB I was able to reproduce your issue. I will look into the analogWrite and digitalWrite source code. In the meantime a quick workaround is to switch to pins 2-4 instead of pin 9-11.

           

          Regards,

          Intel_JEspinoza

           

          Edit:

          I noticed that when using the code you provided: My output on pin 9-11 where Green and a quick flash of red but no blue. On pin 2-4 the lights are Green, Blue then Cyan and loops between Blue and Cyan so my workaround will not work.

          • 2. Re: Galileo analogWrite followed by digitalWrite on Pin 11 operates differently than Arduino Uno
            JPMontero_Intel

            Hi ttrickel

            I tried your code but made some changes, since you are not using the Red LED I deleted those lines but it’s basically the same. I think that the problem is that you’re not setting the pin as an Output. That has happened to me before and the LED behave oddly if you don’t set them with pinMode() function. This is the code that worked for me, I hope it works for you.

             

            const int GREEN_PIN = 10;
            const int BLUE_PIN = 11;

             

            void setup(){
            pinMode(BLUE_PIN, OUTPUT);
            pinMode(GREEN_PIN, OUTPUT);
            }

             

            void loop(){
            analogWrite(BLUE_PIN, 255);
            analogWrite(GREEN_PIN, 0);
            delay(1000);

             

            digitalWrite(GREEN_PIN, HIGH);
            digitalWrite(BLUE_PIN, LOW);
            delay(1000);
            }

            Regards
            JPMontero_Intel