There is no direct connection from Serravalle to Pesaro. However, you can take the drive to Riccione then take the train to Pesaro. Alternatively, you can drive from Serravalle to Pesaro in around 37 min.
How to get from San Marino to Pesaro
From Serravalle drive to Riccione then train to Pesaro. 43 min 6€. From Serravalle drive to Pesaro. 37 min 7€.