Code:
; Filename : 632-I2C-LCD for 12F683.pbp
; Author : Darrel Taylor
; Created : Mon Feb 24 2014
; : May 27, 2015 adapted for the 12F683
; Processor : PIC12F683
; Compiler : PicBasic Pro 3.0.7.x or higher
; Description : Uses PCF8574 Port expander to interface with HD44780 LCD
;
;----[Oscillator Setup]---------------------------------------------------------
define OSC 20
define I2C_SLOW 1
;----[Aliases]------------------------------------------------------------------
SDA VAR GPIO.0 ; I2C Data pin
SCL VAR GPIO.1 ; I2C Clock Pin
;----[Initialize Hardware]------------------------------------------------------
ANSEL = 0 ; Make Analog inputs digital
';----[Setup LCD using PCF8574 Port Expander]------------------------------------
LCD_Addr CON $40 ; A0, A1, A2 grounded
true con 1
false con 0
INCLUDE "LCD_PCF8574.pbp" ; Init LCD using I2C and PCF8574
;----[Variables]----------------------------------------------------------------
LoopCount VAR BYTE
CustChar VAR BYTE
;----[Program Start]------------------------------------------------------------
Backlight = 0 ; Turn on LCD Backlight
LoopCount = 0
ARRAYWRITE LCD_Buff,[" LCD PCF8574"] : LCD_WriteBuff
;----[Custom Characters]-(Jumping Jacks)----------------------------------------
ARRAYWRITE LCD_Buff,[$FE,$40,$00,$04,$0A,$04,$0E,$15,$0A,$11]:LCD_WriteBuff ' #0
ARRAYWRITE LCD_Buff,[$FE,$48,$00,$04,$0A,$04,$1F,$04,$0A,$0A]:LCD_WriteBuff ' #1
ARRAYWRITE LCD_Buff,[$FE,$50,$04,$0A,$15,$0E,$04,$0A,$0A,$00]:LCD_WriteBuff ' #2
;----[Main Program Loop]--------------------------------------------------------
Main:
ARRAYWRITE LCD_Buff,[$FE,$C0,"Count = ",DEC LoopCount," "] : LCD_WriteBuff
PAUSE 200
LoopCount = LoopCount + 1
CustChar = LoopCount//3 ; Jumping Jacks Sequence
ARRAYWRITE LCD_Buff,[$FE,$9D,CustChar] : LCD_WriteBuff
GOTO Main
Bookmarks