Arduino to Pi connection

Does anyone have a good example of sending data from an Arduino to a Pi then having the Pi run an iff loop based on a condition involving the data from the Arduino? I'm trying to send a button push from an Arduino to a Pi then have the Pi send data back based off the data from the Arduino, thanks in advance for the help!!

The Raspberry Pi has to be continuously listening to the Arduino to send something since it doesn't know when the button will be pushed.

On the Arduino side after the button is pushed, it sends the info over to the RPi and then does something when the RPi sends a response.


This simple Python - Arduino demo may help