通用 Arduino PT6314 字符 VFD 写入库,按 PT6314 V1.5 三线串行协议实现,兼容 Arduino Print。库本体只使用标准 Arduino GPIO 和时间 API,不依赖 RP2040、ESP32、AVR、RTOS 或特定厂商寄存器。
This library drives Princeton PT6314 character VFD controllers through the
write-only three-wire serial interface. It uses only standard Arduino APIs and
integrates with Print, so print(), println(), numeric formatting, and raw
byte writes work as expected.
- Independent 16-clock frame for every command and data byte.
- Correct PT6314 Start Bytes: command
0xF8, data0xFA. - MSB-first, SCK idle high, rising-edge data latch, with 2 µs software timing margins.
- Validated one-line (1..80 columns) and two-line (1..40 columns) geometry.
- Display on/off, clear, home, cursor addressing, brightness, and CGRAM glyphs.
Print::write(const uint8_t *, size_t)support for buffer writes.- No Unicode conversion, automatic wrapping, clipping, or readback assumptions.
- Arduino library metadata, example, MIT license, and GitHub-ready documentation.
The constructor keeps the original argument order: PT6314(sck, stb, si). A
named pin structure is also available:
PT6314 vfd(10, 9, 11); // SCK, STB, SI/SO
// or: VFD_Pins pins = {10, 9, 11}; PT6314 vfd(pins);The three signals are:
| Signal | PT6314 function | Driver direction |
|---|---|---|
| SCK | Serial clock | Output, idle HIGH |
| STB | Frame select, active LOW | Output |
| SI/SO | Serial data | Output only |
The driver never requests a read frame, Busy Flag, DDRAM read, or CGRAM read; SI/SO is therefore always configured as an output. Connect all grounds.
With PT6314 VDD1 at 5 V, the datasheet worst-case VIH requirement is above 3.5 V for SI/STB and above 4.0 V for SCK, with fast input edges. A 3.3 V MCU should not be connected directly, and MCU GPIOs are generally not 5 V tolerant. Use a fast 3.3 V-to-5 V buffer such as a suitable AHCT device. Slow BSS138 I2C level-shifter boards are not appropriate for the specified edge rate. A board- level pull-up on the buffered STB signal is recommended so reset leaves the VFD unselected.
#include <PT6314.h>
PT6314 vfd(10, 9, 11); // Change pins for your board.
void setup() {
if (!vfd.begin(20, 2, 100)) {
while (true) { delay(1000); }
}
vfd.setCursor(0, 0);
vfd.print("Hello PT6314");
vfd.setCursor(0, 1);
vfd.print("Arduino Print API");
}
void loop() {}begin(columns, lines, brightness) accepts one-line geometries from 1 to 80
columns and two-line geometries from 1 to 40 columns. Brightness thresholds
match the original driver: 0..25 = 25%, 26..50 = 50%, 51..75 = 75%, and
76..255 = 100%. Brightness 0 does not turn the display off; use
noDisplay() for that.
| API | Behavior |
|---|---|
begin(cols, lines, brightness) |
Configures pins and sends the 100 ms startup sequence. Returns false for invalid geometry, invalid/repeated initialization, or duplicate pins. |
clear() / home() |
Clear DDRAM or return the address counter. PT6314 Busy Flag is not used, so no legacy millisecond delay is added. |
setCursor(column, row) |
Uses row 0 DDRAM offset 0x00 and row 1 offset 0x40; rejects positions outside configured geometry. |
display() / noDisplay() |
Reassert the cached display-control state. |
setBrightness(value) |
Applies the threshold mapping above and reasserts the Function Set frame. |
createChar(slot, rows) |
Writes eight 5x8 rows to slot slot & 7. Call setCursor() afterward because the address counter remains in CGRAM. |
write(value) / write(buffer, size) |
Sends raw bytes unchanged. Every byte receives its own 0xFA frame. |
sendRaw(type, value) |
Sends a complete raw command/data frame and synchronizes cached command state. |
sendByte(value) |
Legacy unframed shifter retained for compatibility; it does not control STB. Prefer send() or sendRaw(). |
The interface is write-only, so a successful method means the local Arduino GPIO
transaction completed; it cannot prove that an external VFD accepted the byte.
Calls should be made from normal setup()/loop() context, not from an ISR. The
generic library does not impose a platform-specific mutex; applications using
multiple tasks or cores must serialize PT6314 operations themselves. A
setCursor() followed by print() is two separate API calls.
Each command/data byte is framed as:
STB LOW -> Start Byte (0xF8 or 0xFA) -> payload byte -> STB HIGH
SCK idles HIGH. For each bit the driver sets SI, waits, drives SCK LOW, waits,
drives SCK HIGH for the latch edge, and holds the level. The timing margins are
implemented with delayMicroseconds(2). Function Set is sent three times after
the 100 ms power-stabilization delay, followed by clear, display-on, and entry
mode initialization.
The repository example is examples/Basic/Basic.ino.
The RP2040-Zero hardware validation sketch is maintained separately in the
Arduino sketchbook and uses STB=GPIO9, SCK=GPIO10, SI/SO=GPIO11. It emits staged
115200-baud serial checkpoints and exercises CGRAM, display control, brightness,
text, numeric printing, and the progress bar.
Example compile command for the Waveshare RP2040-Zero:
arduino-cli compile `
--fqbn rp2040:rp2040:waveshare_rp2040_zero `
path/to/PT6314-test-sketchThe library has also been checked against the Arduino AVR core. Hardware display verification remains visual because PT6314 has no readback path in this driver.
PT6314/
├── PT6314.h
├── PT6314.cpp
├── library.properties
├── keywords.txt
├── LICENSE
├── README.md
└── examples/
└── Basic/
└── Basic.ino
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.