Control Board
How to use Graphic LCD Displays with Raspberry Pi?
How to connect Graphic LCD to Raspberry PI?
The article shows how to hook up a 128×64 graphics LCD display to a Raspberry Pi.
LCD used is a 128×64 with LCD controller of ST7565. It can be powered directly from the Raspberry Pi 3.3V rail. It requires 5 GPIO pins for data.
The schematic is, CS (Chip Select), RST(Reset) and A0 (Register Select) can be connected to any 3 GPIO pins. In this example, 8,24 and 25 are default values. Different values can be specified as parameters when instantiating the ST7565 Python class. SCLK (Serial Clock) on the GLCD goes to GPIO 11 which is the Pi’s serial clock. SID (Serial Input Data) on the GLCD goes to GPIO 10 on the Pi which is MOSI. GPIO 10 and 11 must be used for SID and SCLK. Vdd is connected to a 3.3V pin on the PI and the grounds are also connected.
The LCD has a RGB backlight. The LED pins can go to GPIO’s 16,20 and 21. To control the color from the Pi, specifying RGB pins when instantiate the ST7565 class. The resistors must be placed in series to limit the current to prevent LED breakdown. The LED brightness can be changed by using different values of resistors. It will be best to adjust the current to be around 20mA, of course, different values will result in a different mix of colors. It is very difficult to mix a pure white color. Please calculate the resistor value carefully, at 40mA, the LED brightness will decrease sharply with time, with the current of close to 60mA, the LED might be breakdown and be permanently damaged.
How to program a Graphic LCD?
The display is 128 pixels horizontal by 64 pixels vertical. The LCD can be broken into 8 horizontal pages. They are numbered from 3 to 0 and 7 to 4 up to down. Each page includes 128 columns and 8 rows of pixels. To address the pixels, specifying the page and column number, and send a byte to fill 8 vertical pixels at once.
The display has SPI (Serial Peripheral Interface) to connect to Pi. SPI requires 3 lines MOSI, MISO and Clock. The Pi is the master and the GLCD is the slave. In this example, Only writing to GLCD and not ready, so the connection to MOSI and Clock lines are needed. MOSI is the output from the Pi to the GLCD and the Clock synchronizes the timing.
- Enable SPI on Raspberry Pi first
- From the raspi-config menu, select Advanced Options, then SPI. Then select Yes for “ Would like the SPI interface to be enabled”. Hit OK, Reboot. Select Yes for “ the SPI kernel module to be loaded by default”. Reboot the Pi after enabling SPI. Then test SPI using IsmodIt should return SPI_bcm2708 or spi_bcm2835 depending on the Pi version. The python SPI library requires python2.7 dev which can be installed with apt-get install:
- The Python SPI library is called py-spidev. It can be installed using git:GLCD Python library for the Pi can be downloaded from the GitHub site.
- The main ST7565 library (st7565.py) handles drawing, text & bitmaps, and a font module (xglcd_font.py) to load X-GLCD fonts. Here are the basic drawing commands which to create points, lines, rectangles, circles, ellipses, and regular polygons:For more details, please refer to the reference below or contact our engineers.
Getting started with projects based on STM32G071RB Board using STM32CubeIDE
Getting started with projects based on STM32G071RB Board using STM32CubeIDE
Check out our Control Board!
Getting started with a 32-bit ARM-based microcontroller is always a little daunting. There are too many of available microcontrollers, platforms, development boards, tools, and software. This note describes step by step how to begin a LED project.
Getting started: about Development Board STM32G071RB

Features:
- Core: Arm® 32-bit Cortex®-M0+ CPU, frequency up to 64 MHz
- Up to 128 Kbytes of Flash memory, 36 Kbytes of SRAM
- 7-channel DMA controller with flexible mapping
- 12-bit, 0.4 µs ADC (up to 16 ext. channels)
- Two 12-bit DACs, low-power sample-and-hold
- Two I2C, Four USARTs , one low-power UART , two SPIs
Getting started: Install STM32CubeIDE
You can download STM32CubeIDE from their st.com. It’ s free. Install STM32CubeIDE following STM32CubeIDE installation guide.
Your first project: LED blink
Before we can start writing code we need to create a project. This is similar to most other IDEs – projects are used to bundle together all of your settings, code, and definitions into a single collection all managed from the same application.


STEP 1: Start a new project, From the top left icon ( Or under the menu File > New > STM32 Project) to get started.


Step 2: Project name: G0_LED, then click Finish Button.
From schematic diagram that the LED4 is controlled by STM32G071 and the port is PA5.

Step 3: From System Core > SYS, select Serial Wire, setup PA5 as GPIO_OUTPUT.

Setup use label for PA5 as LED_GREEN as below:

Step 4: Then Generate code.

CubeIDE, which this functionality is developed upon, generates C files to work with under a Src directory, and puts a HAL (Hardware Abstraction Layer) into an Includes directory. It appears CubeIDE works the exact same way. Expand the folders on the right under the project view and see what it has generated to work for you.

Step 5: Let’ s add a smidge of C code of our own now! After the Infinite Loop area, we’re going to add code to toggle the LED under section 3 as below:

Compiling the project and downloading it to the board
STM32CubeIDE actually makes it pretty easy to compile our work and get it onto the STM32 chip. The first step is to produce the compiled .elf ( a binary version of our code). To generate the .elf, we need to do a build. This is as easy as pressing the build button on the toolbar.

Now, build information is presented in the console at the bottom of the screen.
Now what we want to do is send this compiled binary onto the STM32 microcontroller.
Let’s plug in the dev kit:
The Red power LED (to the left of the blue switch) is lit, as is the larger communication LED (by the USB cable). Inside STM32CubeIDE, select the run button.
This will open the Run dialog ( as it’s the first time we’ve run it). The settings we choose now will be saved as a run configuration which we can re-use or edit later.
Simply press Apply and then OK and the download will proceed. The Console will now fill with some interesting text:
The LED is on and off every 500ms. you’ve got everything set up.
STM32 vs Arduino
STM32 vs Arduino
Arduino is more creative, it weakens the operation of specific hardware, its functions and syntax are very simple, and it is very “dumb”.
Most of Arduino’s main control is AVR microcontroller. The advantage of Arduino is that it has high code encapsulation and fewer sentences, which reduces the difficulty of software development.
Arduino is relatively easy to get started, as long as you understand a little hardware and C++, you can develop.
Most of the functions of Arduino have well-built libraries, so it is very simple to use, but the controllability of slightly more complicated functions is poor.
STM32
STM32 pays more attention to engineering practice. In fact, there are many simple instruments in the factory, such as temperature controllers, ordinary motor controllers, low-end PLCs, and some civilian toys, game controllers, wired keyboards and mice, and other peripherals and so on are very practical.
STM32 is mainly used as products for professional developers, which requires certain professional knowledge, but at the same time, it is relatively complicated to write code to realize functions. For example, the serial port outputs a simple string. For Arduino, it may start from a new project and it can be realized with 10 lines of code. However, if you use STM32 development tools such as Keil, it may require hundreds of lines of code or more.
In terms of open source: things made with STM32 can be open source if you want to open source, and you can not publish anything if you don’t want open source.
Conclusion
Here are some suggestions for choosing:
If you are an ordinary student below the university level who does not have a deep understanding of programming languages, it is recommended to get started with Arduino. If the C skills are weak and come up with STM32, you will soon have the idea of giving up.
If you only study for employment, decisively STM32 microcontroller.
If you are learning just for fun and you are not a major in electronics and have no confidence, Arduino is recommended.
If you have good programming skills, STM32 is recommended. After you get it done, you can take a look at the things made by the Arduino open-source community, and you can easily get it done with STM32.
Of course, if you have the ability, you can make contact with both. Generally, you can master the basic features of Arduino in less than a week. If you need it in the future, you can freely transplant the Arduino code to MCU platforms such as STM32.
In fact, the two are actually aimed at slightly different directions. Arduino is the choice of general electronics hobbyists and DIY, while STM32 is often used for the development and manufacturing of actual products.
