Display text on the LCD (AVR + USB-C)
Set up with your favorite AI
Gemini & other AI
Copy the setup prompt into your AI. Work through each step together, from checking your kit to getting it running.
Copy the prompt, then paste it into Gemini’s message box.
View prompt
Use AP01B (AVR MCU), AI04A (LCD), and AZ01C (USB-C) to display Hello! on the first line and Leafony on the second. AI04A has 8 columns and 2 rows, so keep each line within 8 characters.
Hello!Leafony1. Prepare and assemble
Section titled “1. Prepare and assemble”| What you need | Purpose |
|---|---|
| AP01B AVR MCU | Runs the sketch |
| AI04A LCD | Displays 8 characters on each of 2 rows |
| AZ01C USB-C | Provides USB communication and power |
| A USB cable that supports data transfer | Connects the computer to AZ01C |
| A computer and Arduino IDE | Edits and uploads the sketch |
For this first display, use only these three leaves and power them from USB. Remove BLE, CR2032 power, and other leaves.
- Disconnect USB and turn off or disconnect every power source, including batteries. Always do this before adding or removing a leaf.
- Check the part numbers and connector orientation, then connect AI04A, AP01B, and AZ01C. See the FAQ assembly checks for guidance.
- Locate the reset switch on AP01B. If AI04A covers it, see If the reset switch is inaccessible.
- Connect AZ01C to the computer with the USB cable.
2. Configure Arduino IDE
Section titled “2. Configure Arduino IDE”Install the IDE using Arduino IDE setup and select these settings.
| Setting | Value |
|---|---|
| Boards Manager | Arduino AVR Boards (install it if needed) |
| Tools → Board | Arduino Pro or Pro Mini |
| Tools → Processor | ATmega328P (3.3V, 8MHz) |
| Tools → Port | The port that appears when you connect AZ01C |
This configuration does not require an additional Boards Manager URL.
The port name depends on the computer. Possible names include /dev/cu.usbserial-… on macOS, COM… on Windows, and /dev/ttyUSB… on Linux. Select the actual port that appears or disappears when you connect or disconnect AZ01C; do not copy an example name. If no port appears, check that the cable supports data transfer and see AZ01C driver information (Japanese).
3. Install the specified ST7032 library
Section titled “3. Install the specified ST7032 library”This sketch uses arduino_ST7032 by tomozh. It requires this library and the standard Arduino Wire library.
- Open tomozh/arduino_ST7032 and select
Code → Download ZIP. - In Arduino IDE, select
Sketch → Include Library → Add .ZIP Library. - Select the downloaded ZIP file without extracting it first.
LCD_ST7032 and ST7032_asukiaaa, which may appear in library searches, are different libraries. Use the ZIP above for this guide. If compilation reports ST7032.h: No such file or directory, check the library installation and the ZIP file you selected.
4. Prepare the display sketch
Section titled “4. Prepare the display sketch”Create a new sketch in Arduino IDE, replace its contents with this code, and save it.
#include <Wire.h>#include <ST7032.h>
const uint8_t I2C_EXPANDER_ADDR = 0x1A;ST7032 lcd;
void writeExpander(uint8_t reg, uint8_t value) { Wire.beginTransmission(I2C_EXPANDER_ADDR); Wire.write(reg); Wire.write(value); Wire.endTransmission();}
void setup() { Wire.begin();
// AI04A: configure P0 as an output, then turn on LCD power. writeExpander(0x03, 0xFE); writeExpander(0x01, 0x01);
// The ST7032 library handles LCD initialization and its wait times. lcd.begin(8, 2); lcd.setContrast(30); lcd.clear();
lcd.setCursor(0, 0); lcd.print("Hello!"); lcd.setCursor(0, 1); lcd.print("Leafony");}
void loop() {}On AI04A, the I/O expander’s P0 controls LCD power. Writing 0xFE to register 0x03 configures P0 as an output. Writing 0x01 to register 0x01 turns LCD power on. Both steps come before lcd.begin(8, 2).
Calling lcd.begin() followed by lcd.setContrast(30) matches the existing LCD sample. For your first display, use this order and the specified library.
5. Upload with a manual reset
Section titled “5. Upload with a manual reset”In the published AZ01C circuit, the USB-UART interface has no connection that automatically controls AP01B’s RESET. Operate the reset switch on AP01B manually as uploading begins. See AZ01C details for more information.
- Click Verify in Arduino IDE and check that the sketch compiles without errors.
- Close Serial Monitor, Serial Plotter, and any other application using the same port.
- Hold down the reset switch on AP01B and click Upload in the IDE.
- Release the reset switch when the IDE changes from compiling to uploading.
- When the IDE reports that uploading is complete, check both lines on the LCD.
After reset is released, AP01B’s bootloader accepts uploads for a limited time. The available time and the required switch timing depend on the bootloader and other conditions, so there is no fixed number of seconds for this procedure. If uploading fails, recheck the port and board settings, then retry with adjusted reset timing.
6. Troubleshooting
Section titled “6. Troubleshooting”Upload fails with avrdude: not in sync or a similar error
Section titled “Upload fails with avrdude: not in sync or a similar error”Check the selected port, board and processor, other applications using the port, and manual reset timing. This error alone does not identify a faulty LCD leaf or a loose connector.
Unplugging USB will not reset AP01B if another source continues to supply power. Also, the time required for the USB port to reappear is separate from the bootloader’s upload window. Reconnecting USB alone may not align the upload with that window.
If the reset switch is inaccessible
Section titled “If the reset switch is inaccessible”If AI04A covers the switch, you can separate uploading from checking the display:
- Disconnect USB and turn off or disconnect every power source, including batteries.
- Remove AI04A, leaving AP01B and AZ01C connected.
- Connect USB and upload the sketch using the manual reset steps above. Leave the LCD disconnected at this stage.
- After uploading is complete, disconnect USB and confirm that all power sources are off or disconnected.
- Attach AI04A, reconnect USB, and check the LCD.
This procedure provides access to the switch. It does not establish a general fault in which attaching AI04A prevents uploads.
Upload succeeds but no text appears
Section titled “Upload succeeds but no text appears”- Check that the two calls to
writeExpander()come beforelcd.begin(). LCD power and LCD initialization are separate requirements. - Check that you installed
tomozh/arduino_ST7032and included bothlcd.begin(8, 2)andlcd.setContrast(30). - Check the I/O expander address setting. The sketch uses
0x1A. If your AI04A is configured for0x1E, changeI2C_EXPANDER_ADDRaccordingly. - If you need to check assembly and connectors, first disconnect USB and turn off or disconnect all other sources, including batteries.
| Component on AI04A | 7-bit I2C address | Purpose |
|---|---|---|
| PCA9557 I/O expander | 0x1A or 0x1E | LCD power control and switch input |
| ST7032 LCD controller | 0x3E | Initialization and text display |
Detection by an I2C scanner or an ACK indicates a communication response. It does not guarantee correct LCD drive voltage, contrast, or display initialization. See AI04 LCD documentation for notes about controlling the LCD directly with I2C commands.
Asking for help
Section titled “Asking for help”When using the page’s AI help feature or asking for support, share a photo of the leaves, their part numbers and stacking order, the power sources, whether the reset switch is accessible, and the complete IDE error message. State exactly what you observed: for example, the USB leaf’s LED lit up, or text appeared on the LCD.
Next steps
Section titled “Next steps”The LCD sample displays the states of the two switches on the LCD leaf. AI04 LCD collects its display specifications, I2C addresses, and circuit documents. These technical documents remain useful when working with a leaf you already own, including discontinued products.