Unable to open Serial Port

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.(Serial.java:147)
at processing.app.Serial.(Serial.java:82)
at processing.app.SerialMonitor$4.(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.(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);
//NVIC_SET_PRIORITY(IRQ_PORTA, 0)

Serial.begin(9600);
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;
digitalWrite(clk_inh_pin,clk_inh_state);
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);
noInterrupts();
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]``[color=blue]// your code is here[/color]``[/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.

bchsiss:
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”.

bchsiss:
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.

I’m not able to open the serial monitor on arduino IDE. By just having a simple code to print hello world I’m getting the following error after uploading and clicking on the serial monitor icon

Sketch uses 1490 bytes (4%) of program storage space. Maximum is 32256 bytes.
Global variables use 200 bytes (9%) of dynamic memory, leaving 1848 bytes for local variables. Maximum is 2048 bytes.
Sketch uses 1490 bytes (4%) of program storage space. Maximum is 32256 bytes.
Global variables use 200 bytes (9%) of dynamic memory, leaving 1848 bytes for local variables. Maximum is 2048 bytes.
Exception in thread “AWT-EventQueue-0” java.lang.UnsatisfiedLinkError: jssc.SerialNativeInterface.openPort(Ljava/lang/String;Z)J
at jssc.SerialNativeInterface.openPort(Native Method)
at jssc.SerialPort.openPort(SerialPort.java:158)
at processing.app.Serial.(Serial.java:136)
at processing.app.Serial.(Serial.java:82)
at processing.app.SerialMonitor$4.(SerialMonitor.java:101)
at processing.app.SerialMonitor.open(SerialMonitor.java:101)
at processing.app.Editor.handleSerial(Editor.java:2222)
at processing.app.EditorToolbar.handleSelectionPressed(EditorToolbar.java:494)
at processing.app.EditorToolbar.mousePressed(EditorToolbar.java:439)
at java.awt.Component.processMouseEvent(Component.java:6536)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
at java.awt.Component.processEvent(Component.java:6304)
at java.awt.Container.processEvent(Container.java:2239)
at java.awt.Component.dispatchEventImpl(Component.java:4889)
at java.awt.Container.dispatchEventImpl(Container.java:2297)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4532)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
at java.awt.Container.dispatchEventImpl(Container.java:2283)
at java.awt.Window.dispatchEventImpl(Window.java:2746)
at java.awt.Component.dispatchEvent(Component.java:4711)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
at java.awt.EventQueue$4.run(EventQueue.java:733)
at java.awt.EventQueue$4.run(EventQueue.java:731)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

NKC:
I'm not able to open the serial monitor on arduino IDE.

Does the problem still occur after restarting your computer?