How to receive commands to a running arduino program from a raspberry pi?
What you are asking for is not completely trivial, and may be ill-suited
for a beginner's project. You will have to create a protocol for the
communication between the Raspberry Pi and the Arduino (your own
“command language” of sorts), and then implement on the Arduino a
command interpreter that understands this protocol and acts accordingly.
I highly recommend you use a text-based protocol, as this will be way
easier to debug than a binary protocol.
For the Arduino side of the project, you first have to learn how to
read the serial port from the Arduino. Then, you can take a
look at this very basic command line interpreter for
inspiration. Or you can search for Arduino libraries that provide
similar interpreters.
On the Python side, you have to open the serial port (/dev/ttyACM0)
and send your commands through it. The details on how to do that
would be a Python question, which is are out of scope here.