The Arduino Maker Workshop extension provides a collection of snippets to streamline your Arduino development in Visual Studio Code. From basic syntax to advanced ESP32 functionalities, these snippets save time and reduce coding errors.
This extension offers a wide range of Arduino programming snippets, including commonly used functions and advanced ESP32-specific features. It is ideal for beginners and experts alike, simplifying repetitive coding tasks.
Prefix | Description |
---|---|
include |
Insert a generic #include header file. |
includeArduinoHeader |
Include the Arduino core header file (<Arduino.h> ). |
setup |
Create empty setup and loop functions with Serial initialization. |
analogRead |
Read analog data from a specified pin. |
analogWrite |
Write an analog value to a specified pin. |
define |
Insert a #define directive. |
pinMode |
Set up a pin as input, output, or with a pull-up resistor. |
serialBegin |
Initialize Serial communication. |
delay |
Add a delay in milliseconds. |
delayMicroseconds |
Add a delay in microseconds. |
digitalRead |
Read a digital pin's state. |
digitalWrite |
Write HIGH or LOW to a digital pin. |
ifdef |
Insert an #ifdef block for conditional compilation. |
random |
Generate a random number within a range. |
void setup() {
// Initialize your setup code here
Serial.begin(115200);
}
void loop() {
// Add your main code here, to run repeatedly
}
Prefix | Description |
---|---|
taskCreatePinnedToCore |
Create a FreeRTOS task pinned to a specific core. |
TaskHandle_t |
Declare a handle for task management. |
taskFunction |
Create a FreeRTOS task function with setup and loop sections. |
ledcAttach |
Attach a pin to a PWM signal. |
ledcWrite |
Set the duty cycle on a PWM pin. |
ledcAttachChannel |
Attach a pin to a specific PWM channel. |
ledcWriteChannel |
Set the duty cycle on a specific PWM channel. |
ledcRead |
Get the duty cycle of a pin. |
ledcReadFreq |
Get the frequency of a pin's PWM signal. |
ledcWriteTone |
Generate a tone on a pin at a specified frequency. |
ledcWriteNote |
Generate a musical note on a pin. |
ledcDetach |
Detach a PWM signal from a pin. |
ledcFade |
Gradually adjust a pin's duty cycle. |
analogWriteFrequency |
Set the PWM frequency for a pin. |
analogWriteResolution |
Set the PWM resolution for a pin. |
xTaskCreatePinnedToCore(
taskFunction, // Task function
"MyTask", // Task name
8192, // Stack size
NULL, // Task input parameters
1, // Task priority
NULL, // Task handle
1 // Core to run the task on
);
- Open an Arduino file (
.ino
) in Visual Studio Code. - Start typing the snippet prefix (e.g.,
setup
). - Select the desired snippet from IntelliSense or press
Tab
to expand it. - Customize the placeholders (e.g., pin numbers, values) as needed.