Hi, I have attached various sensor devices to my Arduino. They are working individually with the Arduino, and now I need to hook them up together. Problem is I have multiple time measurements going on, and I can't have each device running sequentially by waiting for the previous one to finish.
Here are my time measurements:
- measure a pulse on a pin using pulseIn()
- calculate a pulse width by taking two micros() measurements and subtracting them
- delay a measurement (requires and output and an input) by 60 ms using delay()
I believe #3 is the biggest challenge here but unsure of all at the moment. For #3, I assume we can't do multi-threading so that one process involving a measurement waits for 60 ms, while the #1 and #2 proceed on another thread or forked process?
For #1 and #2, similar thing--it would be nice if I can do non-blocking statements but I believe that is not possible since we're using a variant of C, a procedural language. Is there a command to assign a delay to a specific pin and not wait to run the code that comes after?
Any help is appreciated. Thanks in advance!
(My board: MINI USB Nano V3.0 ATmega328P CH340G 5V 16M Micro-controller board Arduino)