DEV Community

Hedy
Hedy

Posted on

1

How to use VS Code to develop Arduino

Using VS Code for Arduino Development offers better code management, debugging, and extensions compared to the Arduino IDE. Here's a step-by-step guide:

Image description

1. Install Prerequisites
Arduino IDE (required for compiler/tools):
Download from arduino.cc and install.

VS Code:
Download from code.visualstudio.com.

2. Install the Arduino Extension

  1. Open VS Code.
  2. Go to Extensions (Ctrl+Shift+X).
  3. Search for "Arduino" and install the official extension by Microsoft.

3. Configure Arduino Path

  1. Open VS Code settings (Ctrl+,).

  2. Search for Arduino Path and set it to your Arduino IDE installation folder:

  • Windows: C:\Program Files (x86)\Arduino
  • macOS: /Applications/Arduino.app/Contents/Java
  • Linux: /usr/share/arduino

4. Create/Open an Arduino Project
New Project:

  1. Press F1 > Arduino: Initialize.
  2. Select a board (e.g., Arduino Uno).
  3. Choose a sketch folder.

Existing Project:
Open the folder containing your .ino file.

5. Select Board & Port

  1. Click the board name in the bottom status bar (e.g., Arduino Uno).
  2. Select your target board from the list.
  3. Click the port (e.g., COM3 or /dev/ttyACM0).

6. Build & Upload

  • Build (Verify): Ctrl+Alt+R or click the checkmark icon.
  • Upload: Ctrl+Alt+U or click the arrow icon.
  • Serial Monitor: Ctrl+Alt+Shift+M to debug output.

7. Advanced Features
IntelliSense & Autocomplete

  • Install C/C++ Extension (by Microsoft).
  • Configure c_cpp_properties.json (auto-generated by Arduino extension).

Debugging

  1. Install Cortex-Debug extension (for ARM-based boards like Arduino Due).
  2. Use an external debugger (e.g., J-Link) with launch.json.

Library Management

  • Add libraries via Library Manager (F1 > Arduino: Library Manager).
  • Manually place libraries in ~/Arduino/libraries (or your sketchbook folder).

8. Example platformio.ini (Alternative with PlatformIO)
For more control, use PlatformIO in VS Code:

ini
[env:uno]
platform = atmelavr
board = uno
framework = arduino
monitor_speed = 9600
Enter fullscreen mode Exit fullscreen mode

9. Troubleshooting

Image description

10. Recommended Extensions

  • PlatformIO IDE: Advanced project management.
  • GitLens: Version control.
  • Code Runner: Quick script testing.

Why VS Code Over Arduino IDE?

  • Git Integration: Track code changes.
  • Multi-file Projects: Better than Arduino’s single-tab limitation.
  • Debugging: Breakpoints/watch variables (with hardware debuggers).

For beginners, start with the Arduino IDE, but switch to VS Code for larger projects!

Sentry image

Make it make sense

Only get the information you need to fix your code that’s broken with Sentry.

Start debugging →

Top comments (0)

Tiger Data image

🐯 🚀 Timescale is now TigerData: Building the Modern PostgreSQL for the Analytical and Agentic Era

We’ve quietly evolved from a time-series database into the modern PostgreSQL for today’s and tomorrow’s computing, built for performance, scale, and the agentic future.

So we’re changing our name: from Timescale to TigerData. Not to change who we are, but to reflect who we’ve become. TigerData is bold, fast, and built to power the next era of software.

Read more

👋 Kindness is contagious

Explore this insightful write-up, celebrated by our thriving DEV Community. Developers everywhere are invited to contribute and elevate our shared expertise.

A simple "thank you" can brighten someone’s day—leave your appreciation in the comments!

On DEV, knowledge-sharing fuels our progress and strengthens our community ties. Found this useful? A quick thank you to the author makes all the difference.

Okay