This shows you the differences between two versions of the page.
pm:prj2025:iotelea:ana_maria.ailiesei [2025/05/27 23:07] ana_maria.ailiesei [Bibliography and Sources] |
pm:prj2025:iotelea:ana_maria.ailiesei [2025/05/28 00:35] (current) ana_maria.ailiesei [Bibliography and Sources] |
||
---|---|---|---|
Line 276: | Line 276: | ||
joystickButtonPinInterrupt = true; | joystickButtonPinInterrupt = true; | ||
} | } | ||
+ | | ||
+ | | ||
+ | === Documentation for the I2C communication with the LCD === | ||
+ | == Why those hex commands? == | ||
+ | |||
+ | 0x01 Clear Display, 0x02 Return Home, 0x06 Entry-Mode Set, 0x0C Display ON/OFF, 0x28 Function Set – their op-codes and bit-fields are listed in Table 6 "Instructions" of the datasheet. | ||
+ | |||
+ | The Function Set constant 0x28 is 0010 1000b => DL = 0 (4-bit), N = 1 (2-line), F = 0 (5x8 font). You must send this after forcing the controller into 4-bit mode so it knows the final interface width. | ||
+ | |||
+ | == Power-up initialisation (Figure 24 flow) == | ||
+ | <code> | ||
+ | 0x30 -> 0x30 -> 0x30 -> 0x20 | ||
+ | </code> | ||
+ | Send the "0x30 three times" handshake (still in 8-bit mode) and finally 0x20 to drop DL=0. This is the exact 4-bit initialisation sequence shown in Figure 24 "4-Bit Interface Initializing by Instruction" (under Initializing by Instruction). | ||
+ | |||
+ | == 4-bit write cycle (Figure 9) == | ||
+ | In 4-bit mode each byte is split: high nibble first, low nibble second. Figure 9 labels the bus cycles: | ||
+ | |||
+ | | RS | R/W | Cycle name | Purpose | | ||
+ | | 0 | 0 | IR write | Latch a command or address into the Instruction Register | | ||
+ | | 1 | 1 | DR read | Fetch data from DDRAM/CGRAM via Data Register | | ||
+ | |||
+ | See Figure 9 "4-Bit Transfer Example" for the two Enable pulses per byte. | ||
+ | |||
+ | == What the bit-flags in lcd_send_half() do == | ||
+ | |||
+ | | Bit mask | PCF8574 pin → LCD | Why it’s set | | ||
+ | | 0xF0 | P4-P7 -> DB4-DB7 | Carry the nibble you’re transmitting | | ||
+ | | 0x01 | P0 -> RS | 0 = command, 1 = data (selects IR or DR) | | ||
+ | | 0x00 | P1 → R/W kept low | We only write; reads would need a separate read routine | | ||
+ | | 0x04 | P2 -> E | Toggling E high->low latches the nibble; kept >450 ns with delayMicroseconds(2) | | ||
+ | | 0x08 | P3 -> LED+ | Turns the backpack back-light on | | ||
+ | | ||
Line 314: | Line 347: | ||
<html> | <html> | ||
<iframe width="560" height="315" | <iframe width="560" height="315" | ||
- | src="https://www.youtube.com/embed/rlgCxp-0uKw?si=nVdr1mpfgMVzz8b_" | + | src="https://www.youtube.com/embed/1_WvuHkVgRU" |
title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen> | title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen> | ||
</iframe> | </iframe> | ||
Line 337: | Line 370: | ||
[[https://www.flipkart.com/tumtafa-best-quality-labyrinth-game-ball-in-a-maze-round-wooden-kids-adults-party-fun-games-board/p/itm10a21ca18e84c?pid=BDGGGSTBHPG2E3WZ |Ball maze photo]] | [[https://www.flipkart.com/tumtafa-best-quality-labyrinth-game-ball-in-a-maze-round-wooden-kids-adults-party-fun-games-board/p/itm10a21ca18e84c?pid=BDGGGSTBHPG2E3WZ |Ball maze photo]] | ||
+ | |||
+ | [[https://cdn.sparkfun.com/assets/9/5/f/7/b/HD44780.pdf | HD44780 Datasheet]] | ||