Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

reading a 4x4 switch matrix

Status
Not open for further replies.
It works as is.
As for formatting, I realize it may not be "correct" but at least my code works.

I think MrDEB is insinuating my code did not work properly. I assure it works as I wrote it. His modifications to use an LCD were in error. Even after I thoroughly explained his errors, he was unable or unwilling to to fix the two simple errors.

Over 300 posts for 25 lines of code for what should have been a half-hour project. Several verions of working code provided by others. Pretty much unbelievable. At least MrDEB's future programs will be far easier - for me.
 
Jon. Most would have given up at #100 ... You can take a horse to water ..........
CVTsE-KWcAAHNR8.jpg
..
 
I ran Jons suggested code but used an LCD instead of the usart. It runs but doesn't add the 50 as I recall. I will run it again to confirm.
As for posting of code, I use Swordfish and Jon is the only one that I recall posed a working code suggestion in Swordfish.
There are lots of posts that get off the subject.
 
I ran Jons suggested code but used an LCD instead of the usart. It runs but doesn't add the 50 as I recall. I will run it again to confirm.

Don't bother. Because you acrewed up when changing it for the LCD, and completely ignored my posts explaining what you needed to do to make it right , it's not worth any more effort. No matter what you do from here in out, I am done trying to help you. It's not worth my time, effort and sanity writing stuff you are just going to ignore. Please don't say you read every post and try every suggestion. The fact that you screwed up working code and didn't read the post that explained what two lines you left out says otherwise.
 
Last edited:
The fact that I'm not even going to edit the above shows how done I am.

Edit: I did edit the above to make it readable....
 
Last edited:
It works as is.
As for formatting, I realize it may not be "correct" but at least my code works.
MrDEB,

What works for you seems to be very narrow. It would appear that for you that working code must be something that you can just cut and paste in to your Swordfish BASIC environments that will build and run in your prototype hardware.

You have made it impossible for someone new to this forum to offer this kind of help because your Swordfish BASIC project includes modules that are not provided with the Swordfish BASIC tools. Specifically the "IntOSC8.bas" and "Keypad16pullup.bas". These may have been available at one time but at present they cannot be found anywhere that google searches when using those names.

In your interactions on this thread you raise numerous other road blocks for anyone willing to help. The schematics you have posted are chaotic, the code you post lack any useful comments about what you are trying to implement.

To date you have yet to show the technical competence with code development that would lead anyone to believe that you could actually complete the design and implementation of this project.

In post #191 there is a ZIP file that contains a complete and working Swordfish BASIC project for using a 4x4 keypad and an LCD module. What this project does not implement are the calculation methods you want for a Mexican Train dominoes game. As you have not commented on this post it is reasonable to conclude that you have ignored it, you have your reasons.

Your statement that "... at least my code works" implies that other code posted in this thread does not. To this statement I must take exception and declare that just because you cannot get the code to work for you does not mean that the code does not work. What is not working here is your ability to understand the contributions of others to your project.


To all others,

I enjoy your comments and observations especially JonSea, but please step up and get the post count over 500 or I will loose the bet with my wife.
 
500 hundred posts Dan???

I am confident your number is sound, but I suspect MrDEB will break it off into another thread. That thread will be titled "My LCD doesn't work on batteries??? Maybe the 18F25k20 doesn't work on 3.3 volts???? But the LED still flashes????" Because all the comments about 5v LCDs needing a negative bias voltage when operated at a lower voltage have been ignored.

Swordfish Basic modules may be found at the Swordfish Basic Forum or at Digital-DIY.com. On Digital-DIY, it may require searching using the DOCman tool, as many links are broken. Graham revised the site several times and lost interest before everything was cleaned up. The site is still a valuable resource, with many MrDEB-inspired technical articles and other resources, although they may be a little tough to navigate.
 
Seeing how well the 4×4 matrix has worked out, maybe MrDEB should revise his Mexican Train game to use a matrix? Oh, but I guess a 4×4 matrix couldn't work if the switches are arranged in a circle? ;)
 
I stated that the posted code in post #293 worked but does not output the keypressed and add to the total. Basciclly it does work but needed some tweeking to conform to what I wanted. It was pointed out DO NOT ALTER the keypad module. I had to in order to test my code on a perf-board with an LCD mounted on it. I used the basic code that was posted in # 293 and made a few changes to make it work with the LCD.
As for he schematics, they are done in Diptrace and are readable. Maybe the schematics don't follow the format that most use but I have never seen two sets of schematic drawing rules that are the same. And yes, Have completed several projects using Diptrace.
I tried using the matrix n the Mexican train game but didn't want flashing leds as some one pointed out.
The matrix works great in the calculator project as I mentioned before.
And yes I try EVERY suggestion made. I post results but I get the impression certain persons do not read them??
I enjoy writing code but I don't do it 24/7. When it comes to building custom recumbent trikes or irrigation issues then I have a mound of knowledge but get a D or a C when it comes to electronics but am gaining lots of knowledge over the years.
As far as I am concerned this project is pretty much done. Just finishing up the keypad graphics and my combo board (Mexican Train/Bullet Train game boards). And yes both games have been built on a perf-board, component patterns verified for proper size etc. and both work.
 
I stated that the posted code in post #293 worked but does not output the keypressed and add to the total. Basciclly it does work but needed some tweeking to conform to what I wanted. It was pointed out DO NOT ALTER the keypad module. I had to in order to test my code on a perf-board with an LCD mounted on it. I used the basic code that was posted in # 293 and made a few changes to make it work with the LCD....

Yes, you made a FEW changes. Unfortunately, you made TOO few changes AS I CLEARLY STATED IN FOLLOWING PORTS.

Where I was writing ONE line with the UART, you were printing TWO lines to the LCD. AS I POINTED OUT, in the first clause of the if/then statement, you printed ONLY the FIRST line of the LCD with what key was pressed. You DID NOT PRINT the second line, so you didn't get the updated total.

In the ELSE clause of the if/then statement, you printed ONLY THE SECOND LINE OF THE LCD. So the TOTAL was correctly shown, but the KEYPRESS ON THE FIRST LINE was not.

This was explained. At least twice. YOU DIDN'T READ THOSE EXPLANATIONS OR BLEW THEM OFF.

The program is 25 lines. If you are going to continue trying to program, you should be able to follow the logic of a simple 25 line program. There is nothing complicated or unusual in those 25 lines. A grade school kid with 3 days of programming class would be able to follow the logic.

But in the end, you can do whatever you like. You can ask question after question again and again and never really understand anything. The down side of doing that is that you don't have many people left to help you with Swordfish. I dare say zero after this is done because people helping you expect you to learn something. After 9 years of doing this, you should know how to format an if/then statement, have some idea the range of values a byte or word can hold and type your code in such a way that the people who are STILL willing to help can understand it.
 
Here is my code, correcting MrDEB's "Fixes" - for others following along, Comments indicate his omissions. Two lines were missing. One was merely stupid. No need to set a variable = 50, and then convert it to a string to print it.

MrDEB, I DO NOT CARE IF YOU TRY THIS OR IF IT WORKS FOR YOU. It is for others trying to understand. It's worth every penny you paid for it and I am beyond caring.

Code:
WHILE 1 = 1
    WHILE Keypressed = 0 'print key and exit when key pressed
        Keypressed = Keypad16.Value
        IF Keypressed <> 0 THEN
            IF Keypressed = 16 THEN 'Keypressed = double zero
                    Total = Total + 50   //50 added here for 00  //<----you can see here that 50 is added to the total when key 16 is pressed.
                    //WriteAt(1,1,"key pressed =",DecToStr(Keypressed,2))         // double0 = 50   <-----  MrDEB's original line
                    WriteAt(1,1,"Double Zero!!"))       //  <--- no need to set a variable = 50 and print the string of it.
                   // Above line writes the key pressed to the first line of the LCD
                    WriteAt(2,1,"total=",DecToStr(Total,2))        // <---- MrDEB did not include this line, so the total when 00 is pressed is not updated
                ELSE
                    Total = Total + Keypressed
                    WriteAt(1,1,"key pressed =",DecToStr(Keypressed,2))         // <----- MrDEB did not include this line, so keypressed is never updated if not 16.
                    WriteAt(2,1,"total=",DecToStr(Total,2))        // <----  'this line only updates the second line of the LCD
            END IF
            delayms(500)  //  <---- added to address key bounce
        END IF
    WEND
    DELAYMS(100)
    WHILE Keypressed <> 0 'loop until key not pressed
        Keypressed = Keypad16.Value
    WEND
WEND
 
here is my revised code as per suggestion in post #314. NOTE I try out all suggestions to hopefully get an idea whats going on within the code. My original code I was worried that if keypressed = 50 that would throw off all future keypresses but that's not the case. This code snippet was built with several members help.
WHILE True
keypressed = Keypad16.Value
IF keypressed<>0
THEN
DELAYMS(500) // kept getting key bounce the keypad module has a debounce but it apparently didn't work?
WriteAt(1,1," key = ",DecToStr(keypressed,4))
DELAYMS(10)
END IF
IF keypressed = 16 THEN keypressed = 50 // was worried that keypress would stay at 50
'THEN Total = Total + 50 - keypressed //removed from code
WriteAt(1,1,"double blank=",DecToStr(double0,2))// double0 = 50
DELAYMS(500)
WriteAt(1,1," ") //this clears the line very nicely.
END IF
Total = keypressed + Total
DELAYMS(10)
WriteAt(2,1,"Total= ",DecToStr(Total,4))
DELAYMS(10)
WEND
 
An "Oh, now I see what you mean." is too much to expect. As is indented code.

I am glad you have something you are happy with.
 
here is a basic idea of what the project will look like. Need to order boards and have the domino pics printed on white acetate or lables
 

Attachments

  • dom cacul pic.jpg
    dom cacul pic.jpg
    402.1 KB · Views: 179
MrDEB,

I hope your projects do well and wish you success.

The new thread you started regarding a reaction timer looks like it could go the distance.
 
the reaction timer is just something to play with.. The code I wrote is very simplistic at best and really not accurate in displaying actual reaction time.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top