(VS Code) Getting error when compiling simple script

Hey there,

I wanted to run arduino on VS code because of just a more user friendly interface. However setting it up is kind of hard..

I tried running a simple script:

void setup() {
  pinMode(3,OUTPUT);
}

void loop() {
  
}

but I got this instead:

[Starting] Verifying sketch 'servo prototyping.ino'
[Warning] Output path is not specified. Unable to reuse previously compiled files. Build will be slower. See README.
Loading configuration...
Initializing packages...
Preparing boards...
Verifying...
File name servo prototyping.ino is invalid: ignored
java.io.IOException: No valid code files found
at processing.app.Sketch.listSketchFiles(Sketch.java:117)
at processing.app.Sketch.<init>(Sketch.java:54)
at processing.app.Base.<init>(Base.java:422)
at processing.app.Base.main(Base.java:150)
[Warning] Failed to generate IntelliSense configuration.
[Error] Verifying sketch 'servo prototyping.ino': Exit with code=1

This is my configuration:

{
    "configurations": [
        {
            "name": "Win32",
            "includePath": [
                "${workspaceFolder}/**",
                "C:/Program Files (x86)/Arduino/**",
            ],
            "forcedInclude": [
                "C:/Program Files (x86)/Arduino/hardware/arduino/avr/cores/arduino/Arduino.h"
            ],
            "defines": [
                "_DEBUG",
                "UNICODE",
                "_UNICODE",
                "F_CPU=16000000L",
                "ARDUINO=10805",
                "ARDUINO_AVR_UNO",
                "ARDUINO_ARCH_AVR"
            ],
            "windowsSdkVersion": "10.0.19041.0",
            "compilerPath": "C:/Program Files (x86)/Arduino/hardware/tools/avr/bin/avr-gcc.exe",
            "intelliSenseMode": "gcc-x64",
            "cStandard": "c11",
            "cppStandard": "c++11"
        }
    ],
    "version": 4
}

Any help would be appreciated, thanks!

Since you are compiling this in VSCode you will need to add the line:

#include <Arduino.h>

to your program. You will also have to change the file name and extension to main.cpp. The .ino extension is unique to the Arduino IDE.

Are you using the platformIO plugin?

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.