Display Image With Raspberry Pi Pico by Arduino Programming

by Lan_Makerfabs in Circuits > Arduino

7254 Views, 10 Favorites, 0 Comments

Display Image With Raspberry Pi Pico by Arduino Programming

pico_001.jpg

Many people are familiar with Raspberry Pi Pico now, but some people are still very unfamiliar with Pico programming using Arduino. Now this chapter will show you how to program Pico with Arduino and display some pictures on the 1.44inch LCD.

Prepare Hardware

display003.jpg
display002.jpg
pico.jpg

First, I prepared the important roles of this project: Raspberry Pi Pico and 1.44inch LCD. Instead of preparing the display that I had to connect with Pico by many jump lines, I used a Pico kit board that features a 1.44inch LCD. It was convenient and save a lot of time that might have been wasted connecting the screen to the Pico.

The Pico kit board is designed for using Pico conveniently, not only integrated the display but also provide three keys as GPIO input, three LEDs and one buzzer as the GPIO output. In addition to, for expansion to plug kinds of the sensor module, it also provides many interfaces supported UART, I2C, ADC and GPIO. All the pins of the Pico have been available by the 2.54mm interface.

LCD Schematic

display004.jpg

Focus on the 1.44inch LCD, the schematic is shown as the picture. The LCD is controlled by the ST7735 driver, and it connects with the Pico by SPI way. The detail of the connection as the below:

LCD <------ Pico
MOSI <------ GPIO 11
SCK <------ GPIO 10
CS <------ GPIO 13
DC <------ GPIO 14
RES <------ GPIO 15

Refer it, I could config it in the software easily.

Prepare Image

Common images are JPG format or PNG format with different sizes. 1,44inch LCD has 128*128 pixels so that it requires to cut or compress the image to 128*128. convert images into the formats required for UTFT libraries for Arduino with an image converter tool. The converter tool link is: http://www.rinkydinkelectronics.com/t_imageconverter565.php

Use Pico With Arduino First Time

display005.jpg

The version of Arduino IDE I used is V1.8.10, and all the steps I did were base on it. When you use Arduino uploading to Pico first time, follow the steps to start:

1. Install the development library of Pico, open Arduino IDE, and click “Tools->Board->Boards Manager”; search the “Pico” and install the library “Arduino Mbed OS RP2040 Boards”. The library installation is completed.

2. Press the BOOTSEL bottom on the Pico board, then plug it into the PC with the USB cable.

3. Choose the correct port.

4. Upload the code which is empty.

The firmware of Arduino for Pico will be loaded to your Pico board, and you can use your PICO as the normal ARDUINO BOARD. If you want to program Pico with MicroPython, you have to load the MicroPython firmware to it again.

Coding

1. First, install the library that supports the ST7735 display, and I installed the Adafruit one.

2. Program Pico as the Arduino, and it is noticed that the SPI Initialize is different.

SPI = MbedSPI(SPI_MISO, SPI_MOSI, SPI_SCK);

3. You can get the code from Github.

#include <Adafruit_GFX.h>    // Core graphics library
#include <Adafruit_ST7735.h> // Hardware-specific library for ST7735
#include <SPI.h>

#include "a1.h"
#include "pic1.h"
#include "pic2.h"

#define TFT_CS 13
#define TFT_RST 15 // Or set to -1 and connect to Arduino RESET pin
#define TFT_DC 14

#define SPI_MOSI 11
#define SPI_MISO 12
#define SPI_SCK 10

Adafruit_ST7735 tft = Adafruit_ST7735(TFT_CS, TFT_DC, TFT_RST);

void setup(void)
{
    Serial.begin(115200);
    Serial.print(F("Hello! ST77xx TFT Test"));

    SPI = MbedSPI(SPI_MISO, SPI_MOSI, SPI_SCK);

    // OR use this initializer (uncomment) if using a 1.44" TFT:
    tft.initR(INITR_144GREENTAB); // Init ST7735R chip, green tab

    Serial.println(F("Initialized"));

    tft.fillScreen(ST77XX_BLACK);
}

void loop()
{
    //Show logo
    tft.drawRGBBitmap(0, 0, a1, 128, 128);
    delay(3000);
    tft.drawRGBBitmap(0, 0, pic1, 128, 128);
    delay(3000);
    tft.drawRGBBitmap(0, 0, pic2, 128, 128);
    delay(3000);
}

Show

display001.gif