Entering Signal/data to a running Sketch

Can anyone suggest a way of entering data/signal to a Sketch that is running on a UNO. I have designed clock using an Arduino Uno which display time on a 7 seg 4 digit display and day of weel and Date on an LCD Display. What I want to do is select one out of several message to display whilst the clock is running by some means of external signals. I have tried an IRreceiver which is OK in short Sketches but but when incorporated into the clock Sketch it stops the LCD display. Any suggestions would be gratefully received.

Any suggestions would be gratefully received.

Post your code?

Awol - I am sorry but saying 'Post your Code' does not answer the main question I was asking :-Is there a way of getting signal/data into a Sketch from an external source whilst the Sketch is running. ??? If there is please explain.

To answer your question.

YES

Well a "signal" could be seen as meaning reading a pin to see if a switch has been closed. Pretty sure you know how to do that. Or how about typing on your pc keyboard and reading that via Serial?

But AWOL's comment is totally legit: you want someone to suggest how to do something, the suggestion's likely to be more meaningful if the code's visible. Who knows, someone may have a fix to your problem of stopping the display.

It's not just a knee-jerk suggestion to ask for code: help us to help you. Or not, of course.

owddabbler86:
Awol - I am sorry but saying 'Post your Code' does not answer the main question I was asking :-Is there a way of getting signal/data into a Sketch from an external source whilst the Sketch is running. ??? If there is please explain.

I wasn't answering your main question (which was much too broad to be sensibly answered other than by "yes"), I was responding to your request for suggestions.

(Is there something wrong with your '?' key? Maybe turn your keyboard over and give it a shake)

owddabbler86:
Can anyone suggest a way of entering data/signal to a Sketch that is running on a UNO.

There are so many different ways of doing this that I can't figure where to start because I don't know what you have in mind.

If you have a possible solution using IR, why not get that to work?
Hence, "post your code"

...R

Thanks everyone for suggestions. I think that I will attach my code tomorrow when I have more time and then someone may find when why IR kills the Lcd display functioning. I have struggled for a week trying to find what was stopping the displays. I was trying to find some alternative to the IR receiver, hence my original query.

owddabbler86:
I was trying to find some alternative to the IR receiver, hence my original query.

If the problem is in your code rather than your IR receiver switching to an alternative may make no difference.

We will be better able to help when we see your code.

...R

owddabbler86:
I think that I will attach my code tomorrow when I have more time

If the time it takes you to copy and paste is such a burden, I fear this is not the right hobby for you.

I'll take a wild, totally unsubstantiated and speculative guess that the dying lcd is due to a delay() preventing the lcd from getting serviced.

Or a pin thing. If you're using IRremote, it hi-jacks a timer and changes the behaviour of some pins.... pin 3 comes to mind, I lost PWM on that pin for example and a member (PaulS iirc) pointed out that anythng to do with that timer gets wobbly. I don't know if the lcd library could be a victim to that?

Thanks everyone for being patient with me and also for the suggestions. I am attaching my code to this post. You will see that all references to the IR receiver are commented out. Like this the rest of the code works but if I remove the comment marks then it still compiles but the LCD does not display anything. The LCD is connected by I2C which only require two data connections a clock connection and a data connection. Likewise the 7 Seg 4 Digit display. Hope someone can spot some thing to help.

RtcIR.txt (4.87 KB)

If you format your code neatly you will find it much easier to read. You can use the autoFormat tool in the Arduino IDE. It took me a good 5 minutes in my text editor just to get to the stage where I could read your code.

It's a bit of dog's breakfast. I can't see what parts work every time that loop iterates and what parts only work occasionally. If this was my project I would put all the stuff that you have in loop() into several small functions that each deal with one topic. Then it would be easy to add another function to deal with the IR stuff.

Is it updating the matrix on every iteration? Wouldn't once per second be sufficient? That would leave more time for other stuff.

Why are you using while (newDay == true) when IF would seem to more sensible ?

...R

You've got an aweful lot of String type variables in there. These are very inefficient in their use of memory. You are in serious danger of running out of sRam.

I suggest you change as many of them as you can to char arrays. (actually that's probably all of them).

Robin - I agree with you about the 'While (newDay == true)' and that If (new == true) is simpler. But I question why you suggest breaking up the Loop in several functions to deal with smaller actions. I always understood that calling and returning from from functions carried an operating time penalty,

Ken how do you think that changing all my Strings to Char arrays would solve my original problem. As a matter of fact my Sketch compiles to 14,000 bytes compared to 32,000 bytes available. Just to give you a little info into my background I am 86 and was a Computer Programmer for the last 15 years of my working life.

owddabbler86:
Ken how do you think that changing all my Strings to Char arrays would solve my original problem. As a matter of fact my Sketch compiles to 14,000 bytes compared to 32,000 bytes available. Just to give you a little info into my background I am 86 and was a Computer Programmer for the last 15 years of my working life.

Your sketch resides in flash ram, you variables reside in sRam. Totally different things.

Your uno has 32 Kilobytes of flash Ram available for your sketch but only 2kb available for your dynamic data. This includes the stack and heap. The implementation of the String class on an arduino leaks like a sieve. It doesn't take much manipulation with String types to completely crash it.

I always understood that calling and returning from from functions carried an operating time penalty,

It's a clock.
Designed to be read by humans.
Running on a processor that executes one instruction in the time it takes a beam of light to travel about 20 metres.

Ken and Awol thanks for your further clarification to my last queries. I will take your advice and overhaul my Sketch following your suggestions also I have downloaded the latest version of the IR library IRlib_master and will incorporate that to see if that makes any difference. One last question for Robin and Awol. Is it better to position any short functions before rather than after 'void loop()'. ?

owddabbler86:
I always understood that calling and returning from from functions carried an operating time penalty,

I'm sure it does - a very small penalty.

But HEY I DON'T CARE --- I want to write code that saves MY time and writing it in small parts that are easily tested saves me a tonne of time. It also gives me pieces that I can probably copy to other projects.

Have you looked at the Thread planning and implementing a program

...R

Is it better to position any short functions before rather than after 'void loop()'. ?

This isn't a processor like the transputer with faster RAM at lower addresses; it doesn't have a cache either.
Put the functions wherever makes most sense.