Change Pi Pico Serial and I2C Pins and use both I2C Ports

The constructors for these classes are already there, you just have to use them to create new objects.

Test out this program

#include <Arduino.h>
#include <Wire.h>
#include <SPI.h>

// available pins per https://forum.arduino.cc/t/pi-pico-arduino-ide-pin-mapping-for-gpio-in-ide/903691

// default "Wire" object: SDA = GP4, SCL = GP5, I2C0 peripheral
// our new wire object:
#define WIRE1_SDA       2  // Use GP2 as I2C1 SDA
#define WIRE1_SCL       3  // Use GP3 as I2C1 SCL
arduino::MbedI2C Wire1(WIRE1_SDA, WIRE1_SCL);

// default "Serial1" object: UART0, TX = GP0, RX = GP1
// our new Serial object:
#define SERIAL2_TX      4  // Use GP4 as UART1 TX
#define SERIAL2_RX      5  // Use GP5 as UART1 RX
arduino::UART Serial2(SERIAL2_TX, SERIAL2_RX, NC, NC);

// default SPI at MISO = GP16, SS = GP17, SCLK = GP18, MOSI = GP19
// SS/CS is software controlled, doesn't matter which pin
#define SPI1_MISO 12
#define SPI1_MOSI 11
#define SPI1_SCLK 10
arduino::MbedSPI SPI1(SPI1_MISO, SPI1_MOSI, SPI1_SCLK);

void setup() {
    Wire.begin();  // I2C0
    Wire1.begin(); // I2C1

    Serial.begin(115200);  // USB CDC serial
    Serial1.begin(115200); // UART0 serial at TX=GP0, RX=GP1
    Serial2.begin(115200); // UART1 serial at TX=GP4, RX=GP5

    SPI.begin(); // SPI0
    SPI1.begin(); // SPI1 
}

void loop(){

}
1 Like