NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Project Help and Ideas » morse code
April 27, 2013 by uistrol_17 |
hi i was wondering if anyone had tried this program, using the lcd in the kit, i also cleared the timer line in the code, when pressing the button and the lcd shows the characters on line 2, how do you keep the characters continuing onto line 3 then 4? i've been trying to for days. with the counter timer lines cleared( that originally showed on line 3) the characters will start on line 2 then continue onto line 4. can someone help me with this problem? troubled programmer 17 |
---|---|
April 27, 2013 by pcbolt |
17 - I think when the code for that project was written the Nerdkit shipped with the 2-line LCD and not the 4 line LCD the newer kits have (not positive though, I have the newer kit like yours). I looked through the source code they have posted for the USB project and they are using some raw LCD commands to move to location of the next the character placement. The "lcd.c" and "lcd.h" that are part of the newer kits have functions created to do this more easily. You can move to any location with this function call...
You can still use this...
To clear line 2 for example. I'm not sure how you want the program to behave but the "chars" variable in the program keeps track of how many characters are printed so you can use that to decide where you want to print the next character. Keep in mind the LCD updates it's position every time you print one character so you should only have to worry about moving to new lines. The 4 line LCD's are odd because if you go past column 20 on line one it will increment to column 1 on line 3. Same with rows 2 and 4. |
April 28, 2013 by uistrol_17 |
hey pcbolt, that is my problem, im using this code as a lab project( we can use anything online) but i'm trying to fix that problem, when line i go past line 2 the lcd increments to line 4 but i want it to continue from end of line 2 to beginning of line 3 and so on to line 4. i'm still not understanding in how to do this using the given code. |
April 28, 2013 by pcbolt |
17 - I just want to make sure you have the same download I was looking at. It will help as a line reference if me or anyone else needs to change something. Here is the downloaded code...
I'm going to look over it a little more and see if I can find an answer. (Little late tonight :-) |
April 28, 2013 by pcbolt |
17 - Ok I took a better look at the code and I think I can help. There are three places in the code you need to make some changes. First is right around line 226, comment out four lines and add one so it looks like...
Now the next two changes are the same but in two different locations. The first occurs around line 249 and the next at 264. Change that to read...
|
April 28, 2013 by uistrol_17 |
hey pc bolt , i just now tried that new line of code, well what happens, is that the characters do continue to the next line, but for some reason at the beginning line 3 the characters will show then disappear. This only occurs in the first four locations then at location 5 of 3rd line the charcters will stay on screen all the way through end of line 4. Also could you explain (((chars/20)%3)+1,chars%20) means? Also in regarding my question about the pushbutton, yes i am trying to use it to clear the screen for the morse program, i want to clear the screen at any time . i entered those code lines
after line 103 return counter, i'm not sure where to enter this while loop, it tried inserting it after line 55 but it just clears the screen with now switched turned, i think it just prevents program from running. please help |
April 28, 2013 by pcbolt |
On line 295, change the value 21 to 15. I'm posting from a phone so I'll add more later on. |
April 28, 2013 by uistrol_17 |
that part doesnt matter because im not displaying the timer, i noticed that these lines
seem to affect line 3 spaces 1-4. if i comment out line 241, line one doesnt clear out but the characters will not disappear on line 3 space 1-4, but then again line 1 doesnt clear to show dits and dahs for each character. i figure that its the same relation as the previous problem with lines 1 and 3 connected somehow, i cant see anywhere in the code how line 1 is affecting the beginning of line 3. i'll be up late so feel free to reply |
April 29, 2013 by pcbolt |
I thought the old LCD screen was 2x20 but it looks like its 2x25. Try shortening the number of spaces between the " " marks on this line (and all like it) to 20
In regards to what this does...
"chars" is the variable in the program that keeps track of how many characters get printed. "chars/20" (integer division) will be 0 when "chars" is between 0 and 19, 1 when it's between 20 and 39, 2 when it's between 40 and 59 etc, so it's a way of determining which row the character will be printed on (I added 1 so it skips over line one). "chars%20" is the modulus operator and returns the remainder from an integer division. So 1/20 is 0 with a remainder of 1. This is an easy way to convert the character count to a column location. I put the %3 in there so the row numbers will always be between 1 and 3 even when "chars" goes above 60. You may want to clear the screen at this point but that's up to you. As for the PINC code, you shouldn't use a new while loop, just place the code inside the existing while(1) loop (on line 220) ...
|
April 29, 2013 by uistrol_17 |
hey thanks for the tips, i do have one last question, when pressing the button or switch to clear the screen, the screen does clear, but the characters resume in the last spot from when cleared. how do you make it to where after a clear occurs, the characters begin at beginning of line 2, ive tried
after clear thinking that the chars position will resume at first position i also tried using
please help |
April 29, 2013 by pcbolt |
I think you just need to reset "chars" to zero. So the code from the last post should look like...
Everything else should be the same. |
Please log in to post a reply.
Did you know that an analog comparator can tell when one voltage input crosses another? Learn more...
|