I am writing some code that will receive serial data from a Windows program which will comprise a single character and a value that represents a length of time. This serial data will be sent whenever an event is fired, say a button push our mouse click. More or less the Arduino is taking that serial data and turning on a relay for a given amount of time. I am using a steady 5 V signal to actuate the relay, and it is non latching. The problem arises when I try to send multiple messages and a new message is received before the previous signal has been turned off. Is there a way to multithread or at least mimic it to the extent that I don't have to wait for the delay time from the previous message before activating a new relay?
Nathan