MrMark:
Since the signal source is the RPi at 3.3V you don't strictly need a level shifter since the Arduino will read 3.3V as a logic high. It is good practice to use a series resistor (about 1000 Ohms) between Arudino and RPi GPIO pins to limit current. This protects the RPi in case the Arduino pin is accidentally configured as an output.
What do you think of using SparkFun Logic Level Converter - Bi-Directional "BOB-12009". 5V to 3.3V
That way even if the raspberry pi for some reason sends a lower signal we will be able to read it correctly.
If I use that level converter would I still need the resistance?
septillion:
Using an interrupt is useless unless the code can actually break on different places and the start and stop signals are very fast. Other, just poll using digitalRead().
Please, can you explain a little more this sentence? I did not understand it.
MarkT:
Using an interrupt can be faster if its a tight loop you want to control, digitalRead() can take 5us or so,
reading a single boolean variable might only take 0.125us
My loop code will take 800-1000ms to execute so I would have to send an input for at least a second in order to read the input right? In the other hand ISR reads it whenever the input arrives does it?
Thanks to everybody for the help. I am new in electronics, sorry for my little knowledge.
Alexis