My program runs well but I decided to try to tidy it up a little by creating some procedures for the repeatedly used aspects of the code.
I have some code that displays it's output on a 4 line LCD. I have created a procedure using def prepare_output_for_LCD():
All I have done is add the def prepare_output_for_LCD(): line to the start of the code and to move the code from it's original position in my program to the end of my other procedures (that all work very well)
Introducing the procedure is preventing my program from running and causing the following error:
UnboundLocalError: local variable 'lpulse' referenced before assignment.
At the start of the program, I have a line that says lpulse="" and then just before calling it I recalculate 'lpulse'.
I would appreciate help with this because the procedure is only being called from the position where it previously ran perfectly, so I cannot understand why it would be reported as being referenced before assignment.