Go Down

Topic: Unable to open Serial Port (Read 332 times) previous topic - next topic


Having trouble getting to see the Serial Port for a basic clock program. I can see that the program works on my breadboard, but I cannot get to the feedback I need for the test. This error persists even in a basic blink program, so it's nothing to do with the breadboard. Any suggestions?

Here's the error message I get.

Arduino: 1.8.7 (Windows 10), Board: "Arduino/Genuino Uno"

Sketch uses 2780 bytes (8%) of program storage space. Maximum is 32256 bytes.
Global variables use 268 bytes (13%) of dynamic memory, leaving 1780 bytes for local variables. Maximum is 2048 bytes.
C:\Users\admin\Downloads\arduino-1.8.7-windows\arduino-1.8.7\hardware\tools\avr/bin/avrdude -CC:\Users\admin\Downloads\arduino-1.8.7-windows\arduino-1.8.7\hardware\tools\avr/etc/avrdude.conf -v -patmega328p -carduino -PCOM6 -b115200 -D -Uflash:w:C:\Users\admin\AppData\Local\Temp\arduino_build_796128/ISS_p_v2.ino.hex:i

avrdude: Version 6.3-20171130
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\admin\Downloads\arduino-1.8.7-windows\arduino-1.8.7\hardware\tools\avr/etc/avrdude.conf"
An error occurred while uploading the sketch

         Using Port                    : COM6
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
processing.app.SerialException: Error opening serial port 'COM6'.
   at processing.app.Serial.<init>(Serial.java:147)
   at processing.app.Serial.<init>(Serial.java:82)
   at processing.app.SerialMonitor$4.<init>(SerialMonitor.java:101)
   at processing.app.SerialMonitor.open(SerialMonitor.java:101)
   at processing.app.AbstractMonitor.resume(AbstractMonitor.java:104)
   at processing.app.Editor.resumeOrCloseSerialMonitor(Editor.java:2078)
   at processing.app.Editor.access$1400(Editor.java:114)
   at processing.app.Editor$DefaultExportHandler.run(Editor.java:2056)
   at java.lang.Thread.run(Thread.java:748)
Caused by: jssc.SerialPortException: Port name - COM6; Method name - openPort(); Exception type - Port busy.
   at jssc.SerialPort.openPort(SerialPort.java:164)
   at processing.app.Serial.<init>(Serial.java:136)
   ... 8 more
Error opening serial port 'COM6'.

Here's the code, just in case:
const int start_buttonPin = 11;     // the number of the pushbutton pin
const int reset_buttonPin = 4;
const int clk_led_pin =  13;
//const int osc_led_pin =  5;
//const int run_led_pin =  8;
//const int tst_led_pin =  4;
const int clk_inh_pin = 8;
const int clk_rst_pin = 12;
const int count8_pin = 3;

//const int clk_ctr_pin = 2;
//volatile unsigned long clk_count = 0;

// constants won't change:
const long clk_interval = 1000/2;           // (milliseconds)
//const long osc_interval = 100/2;           // (milliseconds)

// Generally, you should use "unsigned long" for variables that hold time
// The value will quickly become too large for an int to store
unsigned long clk_prevMillis = 0;        // will store last time LED was updated
//unsigned long osc_prevMillis = 0;        // will store last time LED was updated
unsigned long clk_cycle = 0;
int start_buttonState = LOW;         // variable for reading the pushbutton status
int reset_buttonState = LOW; 

int clk_state = LOW;
int clk_inh_state = HIGH;
int clk_rst_state = LOW;
int run_state = LOW;

void setup() {
  // initialize the LED pin as an output:
  pinMode(clk_led_pin, OUTPUT);
  pinMode(clk_inh_pin, OUTPUT);
  pinMode(clk_rst_pin, OUTPUT);
  //pinMode(run_led_pin, OUTPUT);
  //pinMode(tst_led_pin, OUTPUT);
  // initialize the pushbutton pin as an input:
  pinMode(start_buttonPin, INPUT);
  pinMode(reset_buttonPin, INPUT);
  pinMode(count8_pin, INPUT);

  digitalWrite(clk_inh_pin, clk_inh_state);
  digitalWrite(clk_rst_pin, clk_rst_state);

//  pinMode(clk_ctr_pin, INPUT);
  attachInterrupt(digitalPinToInterrupt(count8_pin), halt, RISING);
  while (! Serial); // Wait until Serial is ready - Leonardo
  Serial.println("Program started");

void loop() {
//  noInterrupts();
  unsigned long currMillis = millis();
  int start_buttonState = digitalRead(start_buttonPin);         // variable for reading the pushbutton status
  int reset_buttonState = digitalRead(reset_buttonPin); 
  // clock
  if (currMillis - clk_prevMillis >= clk_interval) {
    // save the last time you blinked the LED
    clk_prevMillis = currMillis;
    // if the LED is off turn it on and vice-versa:
    if (clk_state == LOW) {
      clk_state = HIGH;
      clk_cycle = clk_cycle+1;
      Serial.print(clk_cycle, DEC);
    } else {
      clk_state = LOW;

    // set the LED with the ledState of the variable:
    digitalWrite(clk_led_pin, clk_state);
  if (start_buttonState == HIGH && run_state == LOW) {
    clk_cycle = 0;
//    interrupts();
    run_state = HIGH;
    clk_inh_state = LOW;
    Serial.println("Test Running...");
  if (reset_buttonState == HIGH){
    clk_rst_state = HIGH;
    digitalWrite(clk_rst_pin, clk_rst_state);
    delay; 5;
    clk_rst_state = LOW;
    digitalWrite(clk_rst_pin, clk_rst_state);
    Serial.print("Counter Restet.");
//    Serial.println(clk_count ,DEC);
 // digitalWrite(run_led_pin, run_state);
  // if test is running
 // if (run_state == HIGH) {
 //   if (tst_state != clk_state) {
   //   tst_state = clk_state;
    // digitalWrite(tst_led_pin, tst_state);
   // }

//void clk_count_pulse() {
  //clk_count = clk_count + 1;
 // Serial.println(clk_count ,DEC);

void halt(){
  run_state = LOW;
  clk_inh_state = HIGH;
  clk_state = LOW;
  digitalWrite(clk_led_pin, clk_state);
  digitalWrite(clk_inh_pin, clk_inh_state);
  Serial.print("Count Over.");


Please use code tags (</> button on the toolbar) when you post code or warning/error messages. The reason is that the forum software can interpret parts of your code as markup, leading to confusion, wasted time, and a reduced chance for you to get help with your problem. This will also make it easier to read your code and to copy it to the IDE or editor. If your browser doesn't show the posting toolbar then you can just manually add the code tags:
[code]// your code is here[/code]
Using code tags and other important information is explained in the How to use this forum post. Please read it.

Make sure you have the correct port selected from the Tools > Port menu. The port should only show up when you have your Uno plugged in (but you need to reopen the Tools menu to get the Tools > Port menu to refresh).

If you do have the correct port selected, try restarting your computer. Sometimes some temporary glitch can cause this sort of error.

I can see that the program works on my breadboard, but I cannot get to the feedback I need for the test.
It's not clear what you mean by "the program works on my breadboard".
This error persists even in a basic blink program, so it's nothing to do with the breadboard.
It's nothing to do with the code at all. The code compiled fine, but then it couldn't be uploaded.


Try burning the bootloader again.

Go Up