user6263: I am controlling 4 motors using the PWM ports on an Arduino Uno (3,9,10,11). For some reason, the motor hooked up to port 11 doesn't move with my current code. I know it's a code issue because I can create a new basic code that just moves the motor and it works fine, but for some reason it doesn't in this code.
#include <SPI.h>  
#include <Pixy.h>

Pixy pixy;

int personX = 0;
int offCount = 0;

void setup() 
{ 
  pinMode(3, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  Serial.begin(9600);
  while (! Serial);
  pixy.init();
}  

void loop() 
{  
  static int i = 0;
  int j;
  uint16_t blocks;
  char buf[32]; 

  blocks = pixy.getBlocks();

  if (blocks)
  {
    personX = pixy.blocks[0].x;
  }

  if (blocks){
    Serial.println(personX);
    if (personX < 110){
      analogWrite(11, 130);
      analogWrite(3, 130);
      analogWrite(9, 250);
      analogWrite(10, 250);
    } else if (personX > 190){
      analogWrite(11, 250);
      analogWrite(3, 250);
      analogWrite(9, 130);
      analogWrite(10, 130);
    } else {
      analogWrite(11, 190);
      analogWrite(3, 190);
      analogWrite(9, 190);
      analogWrite(10, 190);
    }
    offCount = 0;
  } else {
    if (offCount < 1000){
      offCount = offCount + 1;
    } else {
      analogWrite(11, 190);
      analogWrite(3, 190);
      analogWrite(9, 190);
      analogWrite(10, 190);
    }
  }
} 

Also, when I take the motor and swap it with another, the old one works in the new PWM port, but the new one stops working once I put it in port 11.

user368: Pin 11 is shared between both PWM and SPI. By activating SPI you've disabled PWM from working on that pin. Either use another PWM pin instead, or switch to software SPI on different pins.

6263: <p>I am controlling 4 motors using the PWM ports on an Arduino Uno (3,9,10,11). For some reason, the motor hooked up to port 11 doesn't move with my current code. I know it's a code issue because I can create a new basic code that just moves the motor and it works fine, but for some reason it doesn't in this code.</p>

<pre><code>#include &lt;SPI.h&gt;  
#include &lt;Pixy.h&gt;

Pixy pixy;

int personX = 0;
int offCount = 0;

void setup() 
{ 
  pinMode(3, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  Serial.begin(9600);
  while (! Serial);
  pixy.init();
}  

void loop() 
{  
  static int i = 0;
  int j;
  uint16_t blocks;
  char buf[32]; 

  blocks = pixy.getBlocks();

  if (blocks)
  {
    personX = pixy.blocks[0].x;
  }

  if (blocks){
    Serial.println(personX);
    if (personX &lt; 110){
      analogWrite(11, 130);
      analogWrite(3, 130);
      analogWrite(9, 250);
      analogWrite(10, 250);
    } else if (personX &gt; 190){
      analogWrite(11, 250);
      analogWrite(3, 250);
      analogWrite(9, 130);
      analogWrite(10, 130);
    } else {
      analogWrite(11, 190);
      analogWrite(3, 190);
      analogWrite(9, 190);
      analogWrite(10, 190);
    }
    offCount = 0;
  } else {
    if (offCount &lt; 1000){
      offCount = offCount + 1;
    } else {
      analogWrite(11, 190);
      analogWrite(3, 190);
      analogWrite(9, 190);
      analogWrite(10, 190);
    }
  }
} 
</code></pre>

<p>Also, when I take the motor and swap it with another, the old one works in the new PWM port, but the new one stops working once I put it in port 11.</p>
 368: <p>Pin 11 is shared between both PWM and SPI. By activating SPI you've disabled PWM from working on that pin. Either use another PWM pin instead, or switch to software SPI on different pins.</p>
