I am developing a keyboard read routine. After the key is read
it is displayed on the second line of my LK-202-25 LCD.
The Routine works and displaying characters to the LCD also works
well. however when I am in the loop for decoding the key press I get
an extra character before the one I want to display and 3 extra charactes
after I write to the screen. Does not seem that I am able to attach the jpg image. I can send to anyone that is interested.
I have included my code and a picture of the LCD that shows the strange
characters. This appears only with text written while in the loop. Works
normally otherwise.
I am connected by I2C to a Basic Atom 28 and I use MBasic to code.
Any help would be appreciated
Thank you
Bob Parry
LCD_Read
Array_Counter = 0
LCD_Column = 3
Input_Array = REP 0\4 'Fill Array Full of Zeros
I2Cout SDA,SDC,Address,$20,[254,88] 'Clear Display
I2Cout SDA,SDC,Address,$20,[254,68] 'Disable Line Wrap
I2Cout SDA,SDC,Address,$20,[254,71,$02,$01,"Enter # of Grams",$0D,$0A] 'Start at Column 3 Row 1
Pause 250
Repeat 'Repeat Until Array Loaded or "D" is Entered
Key_Press = 0 'Set Key_Press to 0 for Do Loop
I2Cout SDA,SDC,Address,$20,[254,85,16] 'Set Debounce 'Wait for a Key Press
Do
I2Cin SDA,SDC,Read_Address,$FE,[Key_Press] 'Read the Key Board
If Key_Press = "B" Then '#1 Key on Key Board
Key_Press = 1
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"1"] 'Print "1" at LCD_Column Row 2
Elseif Key_Press = "E"
Key_Press = 2
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"2"]
Elseif Key_Press = "D"
Key_Press = 3
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"3"]
Elseif Key_Press = "G"
Key_Press = 4
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"4"]
Elseif Key_Press = "J"
Key_Press = 5
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"5"]
Elseif Key_Press = "I"
Key_Press = 6
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"6"]
Elseif Key_Press = "L"
Key_Press = 7
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"7"]
Elseif Key_Press = "O"
Key_Press = 8
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"8"]
Elseif Key_Press = "N"
Key_Press = 9
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"9"]
Elseif Key_Press = "T"
Key_Press = 0
Key_Press = Input_Array(Array_Counter)
I2Cout SDA,SDC,Address,$20,[254,71,LCD_Column,$02,"0"]
Elseif Key_Press = "R"
I2Cout SDA,SDC,Address,$20,[254,67] 'Turn Line Wrap Back ON
I2Cout SDA,SDC,Address,$20,[254,88] 'Clear Screen
I2Cout SDA,SDC,Address,$20,["Input Ended"]
Pause 1000
Return
Endif
'Debug [Input_Array,13] 'Debug Code to test value of Input_Array
While Array_Counter <= 3 'Loop until Key Press Detected
Array_Counter = Array_Counter + 1
LCD_Column = LCD_Column + 1
Until Array_Counter = 3
'Repeating until the Letter R
High P15
I2Cout SDA,SDC,Address,$20,[254,67] 'Turn Line Wrap Back ON
Return[/img]
Problem with Odd Characters
Problem with Odd Characters
Bob Parry
The Basic Atom 28 appears to use the format "Address-Byte-Byte" when sending I2C. The Basic Atom "assumes" that you are talking to a memory device and that extra byte is needed. Some development boards have the ability to configure the bytes sent, so only one byte after the address of the device is sent ("Address-Byte"). It appears that the Basic Atom needs another byte and that's the garbage character you see. To solve this problem you can try sendin ("Address - 0xF - Byte"). Give this a try and let me know how it works!! Essentially, ASCII character "15" is a null and this is sufficient for the 2 bytes required.
Miles Y.
Head of Technical Support
Product Manager
Matrix Orbital
Head of Technical Support
Product Manager
Matrix Orbital