How to program the Raspberry Pi Pico board using Arduino IDE Step by step

How to program Raspberry Pi Pico board using Arduino IDE Step by step

Hello and welcome back. In this tutorial, we will learn how to program the Raspberry Pi Pico boards using the Arduino IDE. Therefore, we don’t need any Python knowledge or the Thonny IDE. This method is useful if you’re already familiar with Arduino and want to use the Pico in the same way.  For this tutorial, I used a simple RGB module control example to clearly explain everything. It shows how to control the colors using basic Arduino code. However, you can try this with any other component you have, such as sensors, buzzers, or LEDs.

Ok, let’s do this project step by step. The required components are given below.

Disclosure: These Amazon links are Affiliate links. As an Amazon Associate, I earn from qualifying purchases.

Step 1

Firstly, let’s identify the components.

Step 2

Secondly, place the Raspberry Pi Pico board and the RGB module onto the breadboard.

Step 3

Thirdly, connect the RGB module to the Raspberry Pi Pico board. For that, follow the circuit diagram below.

How to program Raspberry Pi Pico board using Arduino IDE Step by step

Step 4

Now, let’s set up the Arduino IDE. First, open the Arduino IDE and go to Preferences. Then, copy and paste the Raspberry Pi Pico board URL into the Additional Board Manager URLs field.

  • Board Manager URL — https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

Step 5

After that, go to the Board Manager, search for “Pico”, and install the Raspberry Pi Pico boards package.

Step 6

Now, press and hold the BOOTSEL button and connect the Raspberry Pi Pico board to your computer. Then, copy and paste the following program into the Arduino IDE.

const int redPin = 2;
const int greenPin = 3;
const int bluePin = 4;

void setup() {
  pinMode(redPin, OUTPUT);
  pinMode(greenPin, OUTPUT);
  pinMode(bluePin, OUTPUT);
}

void loop() {
  // Pattern 1: Smooth color wheel
  for (int i = 0; i <= 255; i++) setColor(255 - i, i, 0);      // Red to Green
  for (int i = 0; i <= 255; i++) setColor(0, 255 - i, i);      // Green to Blue
  for (int i = 0; i <= 255; i++) setColor(i, 0, 255 - i);      // Blue to Red

  // Pattern 2: Blink primary colors
  blinkColor(255, 0, 0); // Red
  blinkColor(0, 255, 0); // Green
  blinkColor(0, 0, 255); // Blue

  // Pattern 3: Fade white in/out
  for (int i = 0; i <= 255; i++) setColor(i, i, i);            // Fade in white
  for (int i = 255; i >= 0; i--) setColor(i, i, i);            // Fade out white

  // Pattern 4: Random colors
  for (int i = 0; i < 10; i++) {
    int r = random(0, 256);
    int g = random(0, 256);
    int b = random(0, 256);
    setColor(r, g, b);
    delay(500);
  }
}

void setColor(int red, int green, int blue) {
  analogWrite(redPin, red);
  analogWrite(greenPin, green);
  analogWrite(bluePin, blue);
  delay(10);
}

void blinkColor(int r, int g, int b) {
  for (int i = 0; i < 3; i++) {
    setColor(r, g, b);
    delay(300);
    setColor(0, 0, 0);
    delay(300);
  }
}
  • Now, select the Raspberry Pi Pico board and choose the correct port. The first time, it will appear as a UF2 device. Then, click the Upload button. After uploading once, it will show up with your port name, like “Raspberry Pi Pico.”

Now, you can check the RGB light module in action. The full video guide is below. So, we hope to see you in the next project. Have a nice day!

How to program Raspberry Pi Pico board using Arduino IDE Step by step

How to program the Raspberry Pi Pico board using Arduino IDE Step by step

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *