Go Down

Topic: Serial buffering for Arduino RC Car (Read 1 time) previous topic - next topic

abdulazam001

Feb 26, 2013, 12:40 pm Last Edit: Feb 26, 2013, 12:45 pm by abdulazam001 Reason: 1
I want to know how to introduce a delay to my received serial data (like 5 seconds) before arduino executes the move commands for the RC car. Please note the control signals must be processed after 5 seconds  :) (pipelined,buffered), and does not mean that the processing occurs at 5 second intervals  =( . I have an Arduino Uno Rev 3.

PaulS

Quote
I want to know how to introduce a delay to my received serial data (like 5 seconds) before arduino executes the move commands for the RC car.

On each pass through loop(), see if there is serial data. If so, read it. If the data completes a packet, store the time the packet arrived, in one queue. Store the command itself in another queue.

On each pass through loop, see if it is time to execute the first command in the queue. If so, execute it, dequeuing it and the time. It will be time if now minus then (when the command arrived) is greater than the interval you want ("like 5 seconds").

abdulazam001

Thank you PaulS, it worked brilliantly!

Go Up