Go Down

Topic: Access to the COM port (Read 822 times) previous topic - next topic

packocrayons

I just got my first arduino (nano) and I'm trying to upload code to it. It's telling the com port being used is in use somewhere else (COM 6)
Where can I go about finding the COM ports and disabling whatever is currently using that COM port? Or is it as simple as changing the COM port of the device? (which I also forget how to do).

yosler

Are you sure you're using COM 6?
Tools --> Serial Port. That's where to change the port.
Find the COM ports in Control Panel --> Hardware and Sound --> Device Manager.  See if you can find your device.
I'm 13 and I'll frequently be wordy, not writing to the point.
But don't worry, I know somethings about electronics.

packocrayons

#2
Oct 05, 2012, 09:22 pm Last Edit: Oct 05, 2012, 09:27 pm by packocrayons Reason: 1
Yes, It's the only one in the menu, and it's selected.
Under the device manager I'm seeing it as a USB serial port, I can' seem to be able to change the COM port on it.
Hey another kid on here!  :P
Edit: I updated the drivers with ones I found on the internet, It's now seeing the arduino as a serial port on COM 21, but I'm getting the same error: serial port 'Com 21' is already in use, try quitting any programs that may be using it
Edit again: Couple more tries and it worked.

yosler

Maybe try changing the cable to a different port?
Can you post the error (using the code feature)?
I'm 13 and I'll frequently be wordy, not writing to the point.
But don't worry, I know somethings about electronics.

yosler

I'm 13 and I'll frequently be wordy, not writing to the point.
But don't worry, I know somethings about electronics.

packocrayons

Yes, and no. So I got the code to upload and it runs, aside from the loop.
I set one of the LED's to go HIGH during the setup just to make sure it was the loop. It does go high but it never starts the loop. Here is my code:
Code: [Select]
const int fadingled = 9; //fading led pin
int brightness = 0; //brightness of the led
int fadeamount = 5; //how much the led fades
const int colorchange1 = 11; //red dual color pin
const int colorchange2 = 12; //green dual color pin
int colorledstate1 = LOW; //red led state on/off
int colorledstate2 = LOW; //green led state on/off
long previousmillis = 0; //last time LED was updated
long interval = 500; //time between flashes

void setup()   {
  pinMode(fadingled,OUTPUT); //declare all LED's as outputs
  pinMode(colorchange1,OUTPUT);
  pinMode(colorchange2,OUTPUT);
  analogWrite(colorledstate1, HIGH);
}

void loop()   {
  analogWrite(fadingled, brightness); //set the brightness to the LED
  brightness = brightness + fadeamount; //add or subtract to the brightness based on fadeamount
  if (brightness == 0 || brightness == 255) {
    fadeamount = -fadeamount;
  }
  unsigned long currentmillis = millis();
  if (currentmillis - previousmillis > interval)  { //if it has been more than 500 milliseconds
    previousmillis = currentmillis;
    //turn the led off if it's on and vice versa
    if (colorledstate1 == LOW)  {
      colorledstate1 = HIGH;  }
    else {
      colorledstate1 = LOW;  }
      //if the red LED is on, turn the green LED off and vice versa
  if (colorledstate1 == LOW)  {
    colorledstate2 = HIGH; 
  }
  else {
    colorledstate2 = LOW;
  }
  }
}

yosler

When using analogWrite, you must use a number between 0 and 255. Don't use HIGH or LOW.
When using digitalWrite, you must use HIGH or LOW.
The variable you set to HIGH in the setup, that's a variable, not an LED!!

In one of my projects, a Piezo speaker beeps in the setup.
Do you have one? If you do, take a PWM pin not being used, for example, 3. Connect the + to 3 and - to GND.
In the setup write [note the last line]:
Code: [Select]
  tone(BeeperPin, 3000, 1000);               // Play tone for 1 second
  delay(1000);                                       // Delay to finish tone

  pinMode(fadingled,OUTPUT);                //declare all LED's as outputs
  pinMode(colorchange1,OUTPUT);
  pinMode(colorchange2,OUTPUT);
  digitalWrite(colorchange1, HIGH);


Make these changes. Good Luck.
I'm 13 and I'll frequently be wordy, not writing to the point.
But don't worry, I know somethings about electronics.

packocrayons

Alright, it's working now I'm just having problems with the code, I have a thread in the programming section so I'll continue there.
You guys are very helpful, thank you  ;)

Go Up