Problems uploading sketch related to I/O pins

I'm confused. I have a sketch that reads the state of 3 switches on pins 2,3 and 4. Basically a copy of bounce_multiple example in Bounce2 library. Everything works correctly. However I have a relay shield that used pins 4 and 5 so these need to be configured as outputs. If I change the input pins to another 3 contiguous pins such as 6,7, and 8 I get this upload error:

avrdude: ser_open(): can't open device "\.\COM3": The system cannot find the file specified.

If I change configuration and leads back to 2,3,4 everything works fine. What gives? TIA

u are not doing it correctly

BruceO:
I'm confused. I have a sketch that reads the state of 3 switches on pins 2,3 and 4. Basically a copy of bounce_multiple example in Bounce2 library. Everything works correctly. However I have a relay shield that used pins 4 and 5 so these need to be configured as outputs. If I change the input pins to another 3 contiguous pins such as 6,7, and 8 I get this upload error:

avrdude: ser_open(): can't open device "\.\COM3": The system cannot find the file specified.

If I change configuration and leads back to 2,3,4 everything works fine. What gives? TIA

No idea; I think that I would be confused too. Can you post your sketch (the one that causes the error) so we can test; please use code tags when posting the code (see How to use this forum - please read, point 7). Which board?

What do you mean when you change configuration back? You mean the connections? That would imply a wiring mistake - likely you're Ccidentally shorting out the board (which would prevent everything, including the USB serial chip, from functioning)