I have two of these LCD Keypad Shield Modules (Stupid Name) both form the same supplier and less than a fiver a piece. They are slightly different along the top edge where the modifications go. I have been using one of these on a CNC Gear Cutting (Hobbing) Mill for a good while with no problems.
I'm only using these UNO's as they are so cheap. A really good saving on creating a PCB, having our little yellow friends (tongue in cheek ) make 10 PCB's Populate it and test.
I detest the Arduino Language with a passion but now that I can use GCB means I can rattle a project up at a tenth of the cost. Just a pity I couldn't use those LGT328p boards as a substitute for the UNO, Too much cobbling around to make it work the same way with the KeyPad shield.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I've just spent about 20 minutes on Ali and Fleabay looking for WAVGAT LGT328p Uno's ?? Nothing !!.
Boatloads of Uno's with the Atmega Devices but Now't with an LGT328p
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello again Stan, I'm using an Atmega328p Uno with the LCD Keypad Shield. I know I've always said I would never venture onto the Dark Side but hey-ho money talks. these things are as cheap as chips on FleaBay and Ali.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
@Kieth - I would change to use of BIT, ALIASing the BITS to a BYTE then you can reset the ButtonState on each read cycle.
Some code. Shows a BYTE, lots of BITs ALIASed to that BYTE. Then, clear the BYTE and set the BIT within the CASE construct.
Evan
DimButtonStateasByteDimButtonLeftasBitAliasButtonState.0DimButtonRightasBitAliasButtonState.1DimButtonUpasBitAliasButtonState.2DimButtonDownasBitAliasButtonState.3DimButtonSelectasBitAliasButtonState.4DIMBTTNPUSHASWord; MAIN PROGRAMWAIT2SsetLCDBacklightonPRINT" PRESS A BUTTON"WAIT2SDoForeverclsBTTNPUSH=READAD10(AN0)ButtonState=0PrintBTTNPUSHSelectCaseBTTNPUSHCase<50CLSPRINT"RIGHT"ButtonRight=1Case>60&BTTNPUSH<200CLSPRINT"UP"ButtonUp=1Case>200&BTTNPUSH<400CLSPRINT"DOWN"ButtonDown=1Case>400&BTTNPUSH<600CLSPRINT"LEFT"ButtonLeft=1Case>600&BTTNPUSH<800CLSPRINT"SELECT"ButtonSelect=1EndSelectwait2sLOOP
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I may have the answer here. What I found is that reading the AD output into a variable results in a logical 0 being delivered and a value of 255 delivered when the button is pressed.
here is what I have so far in my sandpit. The program is quite big now so I'm only publishing what I have on this part.
chip mega328P, 16
option explicit
include <uno_mega328p.h></uno_mega328p.h>
DIM BTTNPUSH AS Word
DIM XSPMM as Byte
DIM YSPMM as Byte
DIM ZSPMM as Byte
Dim ButtonLeft as Byte
Dim ButtonRight as Byte
Dim ButtonUp as Byte
Dim ButtonDown as Byte
Dim ButtonSelect as Byte
dir portb Out ; Set pin direction
dir portd.0 Out
dir portd.1 Out
dir portd.2 Out
dir portd.3 In
dir portd.4 In
dir portd.5 In
dir portd.6 In
dir portd.7 In
dir portc.5 In
dir portc.4 In
dir portc.3 In
set LCDBacklight on
Do Forever
BTTNPUSH = READAD10(AN0)
ButtonRight = BTTNPUSH < 50
ButtonUp = BTTNPUSH >60 and BTTNPUSH < 200
ButtonDown = BTTNPUSH >200 and BTTNPUSH < 400
ButtonLeft = BTTNPUSH >400 and BTTNPUSH < 600
ButtonSelect = BTTNPUSH >600 and BTTNPUSH < 800
cls
If ButtonRight > 0 then
Print "Right"
Locate 1,0
wait 1 s
End If
If ButtonUp > 0 then
Print "Up"
Locate 1,0
wait 1 s
End If
If ButtonDown > 0 then
Print "Down"
Locate 1,0
wait 1 s
End If
If ButtonLeft > 0 then
Print "Left"
Locate 1,0
wait 1 s
End If
If ButtonSelect > 0 then
Print "Select"
Locate 1,0
wait 1 s
End If
wait 2 s
LOOP
If anyone can spot anything incorrect or can be made more streamlined or efficient the please let me know. Many thanks to all.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Using BIT instead of BYTE only allows me to store logical values 1 or 0. I need to find what is missing in my code which stops it from displaying ASCII characters and symbols when increment or decrement a numeric value.
If ButtonUp > 0 then
XSPMM = XSPMM + 1
EPWrite 0, XSPMM
WAIT 500 mS
End if
If ButtonDown > 0 then
XSPMM = XSPMM - 1
EPWrite 0, XSPMM
WAIT 500 mS
End if
Keith ,
I do not mean to derail you. But have you looked at GRBL software? It is 3 axis CNC gcode translator which means it has the step and dir outputs plus spindle, coolant , limits(hard and soft), lots more. Free! It would save you time.
Mike
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I check the board very, very carefully. I am not aware of any board that is actually correct.
I have two of these LCD Keypad Shield Modules (Stupid Name) both form the same supplier and less than a fiver a piece. They are slightly different along the top edge where the modifications go. I have been using one of these on a CNC Gear Cutting (Hobbing) Mill for a good while with no problems.
Have a hunt around the web. I cannot remember how to test for the fault. I just always fit the diode.
I'm only using these UNO's as they are so cheap. A really good saving on creating a PCB, having our little yellow friends (tongue in cheek ) make 10 PCB's Populate it and test.
I detest the Arduino Language with a passion but now that I can use GCB means I can rattle a project up at a tenth of the cost. Just a pity I couldn't use those LGT328p boards as a substitute for the UNO, Too much cobbling around to make it work the same way with the KeyPad shield.
WAVGAT make a UNO board with an LGT. eBay or Ali is a good place to obtain.
I've just spent about 20 minutes on Ali and Fleabay looking for WAVGAT LGT328p Uno's ?? Nothing !!.
Boatloads of Uno's with the Atmega Devices but Now't with an LGT328p
I just did a quick search.. 'LGT8F328P Arduino Uno Compatible Board' I only found NANO board. Odd.
I should have got 10 !
I have found an arduino sketch which checks out if your keypad shield is defective. It is attached as a compressed file.
I guess it is not very often you are wrong but you're right again - both of mine are reporting as defective or as it say's "BAD"
* Please be very careful with this "Sketch" I have it on good authority That it actually Puts a short circuit across the MCU ***
Last edit: Keith 2022-09-22
Keith, Great find. Post the URL to the original source, then, I attribute a Great Cow BASIC port of the sketch.
I looked at the Sketch. Oh my. It shorts the MCU. Not clever. Let me think if there is a safer way.
Last edit: Anobium 2022-09-19
If the sketch to test if the Keypad Shield is causing a short across the MCU I think I had better take it down - What do you think ??
I would post the URL to the original web page - that way folks can find the the sketch and we remove the risk of someone using without full knowledge.
Sorry @ Keith I didn't know the hardware you use or experience.
Hello again Stan, I'm using an Atmega328p Uno with the LCD Keypad Shield. I know I've always said I would never venture onto the Dark Side but hey-ho money talks. these things are as cheap as chips on FleaBay and Ali.
@Kieth - I would change to use of BIT, ALIASing the BITS to a BYTE then you can reset the ButtonState on each read cycle.
Some code. Shows a BYTE, lots of BITs ALIASed to that BYTE. Then, clear the BYTE and set the BIT within the CASE construct.
Evan
I may have the answer here. What I found is that reading the AD output into a variable results in a logical 0 being delivered and a value of 255 delivered when the button is pressed.
here is what I have so far in my sandpit. The program is quite big now so I'm only publishing what I have on this part.
chip mega328P, 16
option explicit
include <uno_mega328p.h></uno_mega328p.h>
;setup Lcd Parameters
define LCD_IO 4
define LCD_NO_RW
define LCD_SPEED FAST
define LCD_DB4 DIGITAL_4
define LCD_DB5 DIGITAL_5
define LCD_DB6 DIGITAL_6
define LCD_DB7 DIGITAL_7
define LCD_RS DIGITAL_8
define LCD_ENABLE DIGITAL_9
define LCDBacklight DIGITAL_10
define XEN = PORTB.5
define XDIR = PORTB.4
define XPLS = PORTB.3
define YEN = PORTB.2
define YDIR = PORTB.1
define YPLS = PORTB.0
define ZEN = PORTD.0
define ZDIR = PORTD.1
define ZPLS = PORTD.2
define ESTOP = PORTD.4
define XLIMIT_1 = PORTD.5
define XLIMIT_1 = PORTD.6
define YLIMIT_1 = PORTD.7
define YLIMIT_2 = PORTC.5
define ZLIMIT_1 = PORTC.4
define ZLIMIT_2 = PORTC.3
DIM BTTNPUSH AS Word
DIM XSPMM as Byte
DIM YSPMM as Byte
DIM ZSPMM as Byte
Dim ButtonLeft as Byte
Dim ButtonRight as Byte
Dim ButtonUp as Byte
Dim ButtonDown as Byte
Dim ButtonSelect as Byte
dir portb Out ; Set pin direction
dir portd.0 Out
dir portd.1 Out
dir portd.2 Out
dir portd.3 In
dir portd.4 In
dir portd.5 In
dir portd.6 In
dir portd.7 In
dir portc.5 In
dir portc.4 In
dir portc.3 In
set LCDBacklight on
Do Forever
BTTNPUSH = READAD10(AN0)
ButtonRight = BTTNPUSH < 50
ButtonUp = BTTNPUSH >60 and BTTNPUSH < 200
ButtonDown = BTTNPUSH >200 and BTTNPUSH < 400
ButtonLeft = BTTNPUSH >400 and BTTNPUSH < 600
ButtonSelect = BTTNPUSH >600 and BTTNPUSH < 800
cls
If ButtonRight > 0 then
Print "Right"
Locate 1,0
wait 1 s
End If
If ButtonUp > 0 then
Print "Up"
Locate 1,0
wait 1 s
End If
If ButtonDown > 0 then
Print "Down"
Locate 1,0
wait 1 s
End If
If ButtonLeft > 0 then
Print "Left"
Locate 1,0
wait 1 s
End If
If ButtonSelect > 0 then
Print "Select"
Locate 1,0
wait 1 s
End If
wait 2 s
LOOP
If anyone can spot anything incorrect or can be made more streamlined or efficient the please let me know. Many thanks to all.
That will work but a tad slower.
I posted that above before reading your reply above...
Why are you so bloodywell Clever !!
Progress at last. Thank you.
Pleasure
@Keith
then you use dir portb.5 in
why not dir XEN in ?
Is the equals optional ie #define XEN portb.5
What have I done wrong? My Data Value is incrementing in ASCII characters and symbols ??
Is there something I haven't told it or perhaps something I have. GRR ! This doesn't happen with Microchip MCU's
Nothing wrong. I would use BITs, you used BYTEs. A working solution either way with a tad more RAM used. I would not worry the UNO has plenty of RAM.
Is the idea that you use 5 buttons with resistors and and measure the a-d voltage to determine which button was pressed?
Using BIT instead of BYTE only allows me to store logical values 1 or 0. I need to find what is missing in my code which stops it from displaying ASCII characters and symbols when increment or decrement a numeric value.
as thus:
PRINT "X Motor"
Locate 1, 2
Print XSPMM
Locate 1, 6
Print "Steps/mm"
If ButtonUp > 0 then
XSPMM = XSPMM + 1
EPWrite 0, XSPMM
WAIT 500 mS
End if
If ButtonDown > 0 then
XSPMM = XSPMM - 1
EPWrite 0, XSPMM
WAIT 500 mS
End if
I have attached the full project here
Last edit: Keith 2022-09-19
I think I have found what is wrong.
DIM XSPMM as Integer seems to have fixed it
Keith ,
I do not mean to derail you. But have you looked at GRBL software? It is 3 axis CNC gcode translator which means it has the step and dir outputs plus spindle, coolant , limits(hard and soft), lots more. Free! It would save you time.
Mike