wifi.connect
memclear
cls
let address = 39 'PCF8574 I2C Address
i2c.setup(4,5) 'choose your I2C bus pins
print ("P7 P6 P5 P4 P3 P2 P1 P0 --- PCF8574")
print (" | | | | | | | |")
print ("D7 D6 D5 D4 Blacl. EN R/W RS --- HD44780")
'step1
delay 150
'step2
i2c.begin(address)
i2c.write(52) '0011 0100b=52
i2c.write(48) '0011 0000b=48
i2c.end()
delay 5
'step3
i2c.begin(address)
i2c.write(52) '0011 0100b=52
i2c.write(48) '0011 0000b=48
i2c.end()
delay 1
'step4
i2c.begin(address)
i2c.write(52) '0011 0100b=52
i2c.write(48) '0011 0000b=48
i2c.end()
delay 1
'step5
i2c.begin(address)
i2c.write(36) '0010 0100b=36
i2c.write(32) '0010 0000b=32
i2c.end()
delay 1
'step6
i2c.begin(address)
i2c.write(36) '0010 0100b=36
i2c.write(32) '0010 0000b=32
i2c.end()
i2c.begin(address)
i2c.write(132) '1000 0100b=132
i2c.write(128) '1000 0000b=128
i2c.end()
delay 1
'step7
i2c.begin(address)
i2c.write(4) '0000 0100b=4
i2c.write(0) '0000 0000b=0
i2c.end()
i2c.begin(address)
i2c.write(132) '1000 0100b=132
i2c.write(128) '1000 0000b=128
i2c.end()
delay 1
'step8
i2c.begin(address)
i2c.write(4) '0000 0100b=4
i2c.write(0) '0000 0000b=0
i2c.end()
i2c.begin(address)
i2c.write(20) '0001 0100b=20
i2c.write(16) '0001 0000b=16
i2c.end()
delay 5
'step9
i2c.begin(address)
i2c.write(4) '0000 0100b=4
i2c.write(0) '0000 0000b=0
i2c.end()
i2c.begin(address)
i2c.write(100) '0110 0100b=100
i2c.write(96) '0110 0000b=96
'0 1 I/D S,0110=6D
'I/D=1;Increment by 1
'S=0;No shift
i2c.end()
delay 1
'step10
'Initialization ends
'step11
i2c.begin(address)
i2c.write(4) '0000 0100b=4
i2c.write(0) '0000 0000b=0
i2c.end()
i2c.begin(address)
i2c.write(196) '1100 0100b=196
i2c.write(192) '1100 0000b=192
'1 1 C B
'C=0;Cursor off
'B=0;Blinking off
i2c.end()
delay 100
'Display:
'H e l l o space
'72D 101D 108D 108D 111D 32D
'0100 1000, 0110 0101, 0110 1100, 0110 1100, 0110 1111, 0010 0000
i2c.begin(address)
i2c.write(77) '0100 1101=77
i2c.write(72) '0100 1000=72
i2c.write(141) '1000 1101=141
i2c.write(136) '1000 1000=136-->H
i2c.write(109) '0110 1101=109
i2c.write(72) '0110 1000=104
i2c.write(93) '0101 1101=93
i2c.write(136) '0101 1000=88-->e
i2c.write(109) '0110 1101=109
i2c.write(104) '0110 1000=104
i2c.write(205) '1100 1101=205
i2c.write(136) '1100 1000=200-->l
i2c.write(109) '0110 1101=109
i2c.write(104) '0110 1000=104
i2c.write(205) '1100 1101=205
i2c.write(136) '1100 1000=200-->l
i2c.write(109) '0110 1101=109
i2c.write(104) '0110 1000=104
i2c.write(253) '1111 1101=253
i2c.write(248) '1111 1000=248-->o
i2c.write(45) '0010 1101=45
i2c.write(40) '0010 1000=40
i2c.write(13) '0000 1101=13
i2c.write(8) '0000 1000=8-->space
i2c.end()
'W o r l d
'87D 111D 114D 108D 100D
'0101 0111, 0110 1111, 0111 0010, 0110 1100, 0110 0100
i2c.begin(address)
i2c.write(93) '0101 1101=93
i2c.write(88) '0101 1000=88
i2c.write(125) '0111 1101=125
i2c.write(120) '0111 1000=120-->W
i2c.write(109) '0110 1101=109
i2c.write(104) '0110 1000=104
i2c.write(253) '1111 1101=253
i2c.write(248) '1111 1000=248-->o
i2c.write(125) '0111 1101=125
i2c.write(120) '0111 1000=120
i2c.write(45) '0010 1101=45
i2c.write(40) '0010 1000=40-->r
i2c.write(109) '0110 1101=109
i2c.write(104) '0110 1000=104
i2c.write(205) '1100 1101=205
i2c.write(136) '1100 1000=200-->l
i2c.write(109) '0110 1101=109
i2c.write(104) '0110 1000=104
i2c.write(77) '0100 1101=77
i2c.write(72) '0100 1000=72-->d
i2c.end()
[quit]
end
!!! Not perfect but it works !!!