You can use this code with [comport] and an abstraction I made, [serial_print] (if you're on extended then use [serial_print_extended]), which you can get from my GitHub https://github.com/alexdrymonitis/Arduino_Pd
The only modification you'll need to do is to replace some white spaces. In the loop() function, the code reads:
Serial.println(" was touched");
change the last line with:
Do the same for further down where it reads:
and close to the end where it reads:
In [serial_print] the white space is read as a separator (it can be used in a string, but with this code it's not really functional).
Lastly, int the setup() function there's a line that reads:
Serial.print("begin to init");
put two forward slashes at the beginning of the line (//) to comment it out, as this string is not very helpful in Pd. If you really need it, you'll need to modify it.
In Pd, do the following:
[comport 1 9600] <- the 1st argument is the port number and the 2nd the baud rate (the 1st might be different in your computer)
You'll receive data using the strings "pin" and "pad" in [receive]s. Use print to see the data that comes out and use that data as you wish.
Read [serial_print]'s help patch to see how it works.