COM3: acces denied?

Hello forum.arduino.cc,

I'm relatively new to Arduino. I've tinkered wit them a little, but nothing big, really.
A few days ago, a friend of mine suggested that we could add a speaker to a project we're working on to make it play Africa by Toto in an 8-bit fashion.

I soldered some wires to an old speaker that we salvaged from a walkie-talkie, connected it to my Nano, and uploaded a basic C3 to C4-sketch. It uploaded fine after I changed the processor to the ATmega328P (Old Bootloader).

Now here's the thing: when I tried to upload the actual music sketch, the Port menu was greyed out, so I couldn't select COM3. I verified the sketch and it contained no bugs. However, when I tried uploading the sketch, it didn't work at all.
The error message read: avrdude: ser_open(): can't open device "\.\COM3": Het systeem kan het opgegeven bestand niet vinden. (The system can't find the specified file)


My details:

  • OS: Windows 8.1
  • Arduino IDE Version: 1.8.7
  • Arduino: Nano, ATmega328P with the old bootloader (not exactly sure what that means)

And finally my code:

int tonePin = 3;
void setup() {

}

void midi() {

    tone(tonePin, 110, 136.5);
    delay(150.0);
    delay(300.0);
    tone(tonePin, 277, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 277, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 110, 136.5);
    delay(150.0);
    tone(tonePin, 277, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 246, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 138, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 369, 136.5);
    delay(150.0);
    tone(tonePin, 329, 136.5);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 329, 136.5);
    delay(150.0);
    delay(300.0);
    tone(tonePin, 277, 136.5);
    delay(150.0);
    delay(300.0);
    tone(tonePin, 277, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 277, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 110, 136.5);
    delay(150.0);
    tone(tonePin, 277, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 246, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 329, 136.5);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 369, 136.5);
    delay(150.0);
    tone(tonePin, 329, 136.5);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    delay(150.0);
    tone(tonePin, 329, 136.5);
    delay(150.0);

}

void loop() {
    // Play midi
    midi();
}

Thanks in advance,
WalrusGumboot

If the tools -> port menu is greyed out, the computer can't see the arduino. It's either a hardware problem, a driver problem (was it the same computer you used it successfully with? If so, that would imply the drivers are fine) or a bad USB cable (There are a lot of crap USB cables and charging only USB cables making the rounds lately). A thing to try would be to disconnect everything from the nano - if the COM port now appears, you have something wrong with your wiring (likely a short or excessive load) that's keeping the nano from operating when that's connected to it.

The "old bootloader" thing - as of like, febuary 2018 or so, official nano's are shipping with a new bootloader that uses a different baud rate and fixes the WDT reset bug (unfortunately, if they'd changed two numbers in the board def, and built with a different start address, they could also have gotten an extra 1.5k of code space - but they didn't). To use old boards with versions of the IDE that support the new bootloader, you need to select the "old bootloader" option.

Finally - This isn't your problem, but delay does not take a float; it's just getting truncated to an integer. So you should change all those delay(150.0) to delay(150).