I have a code for communicating between a phone and an Arduino to make an alarm for a scooter. My problem is that I don’t know how to make the program run in the background (when the phone is in sleep mode or the app is closed).
processing android is imho not supporting background services, at least never heard or tested it…
You should take a closer look regarding alarms and background services/tasks for Android here…