001 - MakeCode MicroBit: Brickcell LCD I2C
Table of Contents
Brickcell Development Kit comes with an LCD module which is a 16x2 LCD module with an I2C interface.
It has an alphanumeric dot matrix display screen, an HD44780 display controller developed by Hitachi, and a PCF8574T I2C to GPIO expansion IC which converts parallel IO to I2C. The LCD module can be access through 0x20 I2C address.
Working Details
- The I2C interface can only work with 4-bit mode (no 8-bit mode support).
- Register Select (RS pin):
- Data register - contains what is displayed on the LCD
- Instruction register - contains instructions for the display controller.
- Read/Write (R/W pin):
- Reading mode
- Writing mode
- Enable pin
- Data bus (8 bits, bi-directional) pin
Hardware Instruction
Let's explore how to connect the LCD I2C to a micro:bit microcontroller and utilize MakeCode for programming.
- Connect the LCD GND pin to microbit GND pin.
- Connect the LCD VCC pin to microbit VCC pin.
- Connect the LCD SDA pin to microbit pin 20.
- Connect the LCD SCL pin to microbit pin 19.
Software Instruction
Now, let's start programming the micro:bit to utilize the NTC temperature sensor.
- Login to https://makecode.microbit.org/ using your Microsoft account.
- Create a new project by clicking the “New Project” button. You may name it anything you want — for example, lcd-i2c-test.
- Click the “Extensions” block just under the “Math” block.
- Type https://github.com/gbantique/brickcell-lcd-i2c/ in the search bar.
- Select the “brickcell-lcd-i2c” from the search results. The “lcd i2c” block should appear under the “Brickcell” block.
- Copy the code provided below.
let loopCount = 0
Brickcell.init(0)
Brickcell.ShowString("Brickcell", 0, 0)
basic.forever(function () {
loopCount += 1
Brickcell.ShowNumber(loopCount, 0, 1)
basic.pause(1000)
})
Or you can make a copy of my created project in your MakeCode workspace:
https://makecode.microbit.org/S97995-99534-94247-46039/
Expected Result
If you carefully follow the provided instructions above, you should be able to view the following on the LCD:
- First line: the word Brickcell
- Second line: a counter value that increases every 1000 milliseconds.