Hey forums,
I have been having a go at making a morse code translator where you input morse code with a button which is then outputted on the screen alongside a translation.
I finished it a few weeks ago and everything was working perfectly. However, I have brought it out again today and now odd characters appear randomly on the screen. There is no particular pattern to when the random symbols appear.
Below is my github repository with my code and schematics:
I have also attached images of the display for the symbols and the wiring!
Thank you for your time!
EDIT: I'm imagining it may be something to do with wiring or the electronics as the code gives the correct outputs and moves the cursor correctly. But I have been triple checking wiring as well as using different wires to no avail. I heard that the screen can be very sensitive to fluctuations but not sure how to fix that (I am very new to electronics).
SOLUTION: I went over my code and decided that I had too many global variables being accessed by too many functions. After changing structure types, removing any irrelevant variables, and having functions pass by reference where needs be, I managed to eliminate the problem!
Try temporarily removing the piezo speaker and see what happens.
Don
floresta:
Try temporarily removing the piezo speaker and see what happens.
Hey Don,
Thank you for your reply and help!
I was wrong and realised it was my code in the end. Too many global variables and too many functions accessing them. I changed structures and changed the functions outside of the loop to call by reference rather than accessing the global variable directly.
The edited code will be uploaded to my repository for people to look at as well.
Thank you again!
I am horrified by your 100R pot for LCD contrast. It will work but it seems an unnecessary waste of 50mA.
10k is more common.
Your Active-high Morse Key will work (with your external pull-downs). But active-low would be easier e.g. with the internal pull-ups.
David.
david_prentice:
I am horrified by your 100R pot for LCD contrast. It will work but it seems an unnecessary waste of 50mA.
10k is more common.
Haha, I'm sorry about that! Realised that value isn't supposed to be there! I'm very new to arduino and electrical circuits so I used the example in the starter kit to help me set up the LCD. It's a potentiometer instead of a resistor.
david_prentice:
Your Active-high Morse Key will work (with your external pull-downs). But active-low would be easier e.g. with the internal pull-ups.
I kind of understand what you're saying but isn't my morse switch active-high anyway since pressing the switch down gives a signal of 1? As I said, I'm very new but would appreciate making my build more efficient if possible (or is it more a question of ease rather than efficiency?).
Active-low buttons are wiser from an electrical point of view.
From a human point of view, active-high is easier to follow.
The trick is to read the Port and flip the bits. Mask out any irrelevant bits.
Then you have intuitive Logic for your program and good electrical practice for your hardware.
David.