This is how I read on the pi what arduino is sending:
#!/bin/bash
set -x
ALTWERT=1
while true
do
WERT=$(head -n 1 < /dev/ttyACM0)
WERT=$(echo $WERT | sed "s:\r::")
NUMBSTATIONS=$(mpc playlist | wc -l)
if [ $ALTWERT -ne $WERT ]; then
mpc play "$WERT"
ALTWERT=$WERT
#sleep 1
fi
#echo "$NUMBSTATIONS\n" > /dev/ttyACM0
done
Variable WERT is filled with what is coming from arduino. So by turning the pot I can "tune" through my playlist.
Variable NUMBSTATIONS hold the number of radio stations in my playlist. This is the value that I want to echo to the pot.
Echo is commented # in the code above;
But as I leared in this thread in the last two hours "echo" does not work in this case.