Re: Pixy and Mega 2650 error compilation

Hello, I have two codes, where the error behaves similar.

For this code it displays" Error Opening Serial Port ' COM4' 9Port Busy), An error occured while uploading the sketch..

same as the other one, I wonder how does arduino behave in terms of ports and how information can I not just direct a set code to one bus?

I know its a compact microcontroller, but its been awhile and I did not intend on helping these teenagers to make a follow me cart type of project.

If any idea is good positive or scathing otherwise...

Thank You

#include <ZumoMotors.h>
#include <Pixy2.h>
#include <Pixy2Line.h>
#include <Pixy2Video.h>
#include <TPixy2.h>
#include <Pixy2CCC.h>
#include <Pixy2I2C.h>
#include <Pixy2UART.h>
#include <ZumoBuzzer.h>
#include <PIDLoop.h>
#include <Pixy2SPI_SS.h>

#include <Servo.h>

Servo FR;
Servo FL;
Servo BR;
Servo BL;



int data[3] = {0, 0};
int getdata[3] = {0, 0};



//
// begin license header
//
// This file is part of Pixy CMUcam5 or "Pixy" for short
//
// All Pixy source code is provided under the terms of the
// GNU General Public License v2 (http://www.gnu.org/licenses/gpl-2.0.html).
// Those wishing to use Pixy source code, software and/or
// technologies under different licensing terms should contact us at
// cmucam@cs.cmu.edu. Such licensing terms are available for
// all portions of the Pixy codebase presented here.
//
// end license header
//
// This sketch is a good place to start if you're just getting started with 
// Pixy and Arduino.  This program simply prints the detected object blocks 
// (including color codes) through the serial console.  It uses the Arduino's 
// ICSP SPI port.  For more information go here:
//
// https://docs.pixycam.com/wiki/doku.php?id=wiki:v2:hooking_up_pixy_to_a_microcontroller_-28like_an_arduino-29
//
  
#include <Pixy2.h>

int x=0;
int y=0;
int A=0;

// This is the main Pixy object 
Pixy2 pixy;

void setup()
{
  Serial.begin(115200);
  Serial.print("Starting...\n");
  
  pixy.init();

  FR.attach(10);
  FL.attach(8);
  BL.attach(9);
  BR.attach(11);

  FR.write(90);
  FL.write(90);
  BL.write(90);
  BR.write(90);
  delay(1000);

  Serial1.begin(9600);
  Serial2.begin(9600);
  delay(3000);
}

void loop()
{ 
  int i; 
  // grab blocks!
  pixy.ccc.getBlocks();
  

  \
  // If there are detect blocks, print them!
  if (pixy.ccc.numBlocks)
  {
    
    for (i=0; i<pixy.ccc.numBlocks; i++)
    {
      A=pixy.ccc.blocks[i].m_width * pixy.ccc.blocks[i].m_height;
      x=pixy.ccc.blocks[i].m_x;
      y=pixy.ccc.blocks[i].m_y;
      
    Serial.print("width");
    Serial.print('\t');
    Serial.print(A);

    
    Serial.print('\t');
    Serial.print(x);
    Serial.print('\t');
    Serial.print(y);
    Serial.print('\t');
    Serial.print(pixy.ccc.blocks[i].m_signature);
    if(pixy.ccc.blocks[i].m_signature != 4)
    {
    CV();
    }else{
     stopMe();
    }
    
    
    }
  }else
  {
    stopMe();
  }
}

void CV()
{
  int powerValue=90-map(A,0,20000,0,90);
  
  if(A>20000){
    A=20000;
  }
  if(A<20000)
  {
    int motorPower=90+powerValue;
    Serial.println(motorPower);
    FF(motorPower);
  }else{
    stopMe();
  }
}

// FF 90 TO 180
void FF(int x) {

  Serial.println("Forward FF");

  FR.write(x);
  BR.write(x);
  FL.write(x);
  BL.write(x);
}
//BB 90 TO 180
void BB(int x) {

  Serial.println("Backward BB ");

  FR.write(x);
  BR.write(x);
  FL.write(x);
  BL.write(x);
}

// RR 0 TO 90 forward
void RR(int x) {

  Serial.println("RIGHT RR ");

  FR.write(180 - x);
  BR.write(x);
  FL.write(x);
  BL.write(180 - x);
}
//LL 90 TO 180 forward
void LL(int x) {

  Serial.println("LEFT LL ");

  FR.write(180 - x);
  BR.write(x);
  FL.write(x);
  BL.write(180 - x);
}
//DFR 0 TO 90
void DFR (int x) {
  Serial.println("Diagonal   1st QD  DFR ");

  BR.write(x);
  FL.write(x);
}
//DBL 90 TO 180
void DBL(int x) {
  Serial.println("Diagonal   3rd QD   DBL ");
  BR.write(x);
  FL.write(x);
}

//DFL 0 TO 90
void DFL(int x) {
  Serial.println("Diagonal   2nd  QD   DFL ");
  BL.write(x);
  FR.write(x);
}

// DBR  90 TO 180
void DBR(int x) {
  Serial.println("Diagonal   4nd  QD   DBR ");
  BL.write(x);
  FR.write(x);
}
// Stop
void stopMe() {

  Serial.println("Leave me alone I am in my DEAD ZONE  ");
  FR.write(90);
  BR.write(90);
  FL.write(90);
  BL.write(90);
}


void SpinR(int x) {
  Serial.println("SPin on my back ");
  FL.write(x);
  BL.write(x);
  FR.write(180 - x);
  BR.write(180 - x);
}

void SpinL(int x) {
  Serial.println("Spin on my Back Right wheel ");
  FL.write(180 - x);
  BL.write(180 - x);
  FR.write(x);
  BR.write(x);
}