Have a look here
And about the MCP23008, why not have a look at the samples in the dedicated library?Particle Web IDE
Developing software is not only about putting lines of code - found somewhere else - together but about reading these lines, understanding what they do and why and then use that knowledge to adapt the code to fit your own needs.
If you have problems understanding the what and why, you can aske specific questions about that, but just asking: "What do I have to change to make it work?", is not really the way we tend approach things here in this community.
Just one thing about
I would not. I would use arrays and enums and stay away from #define
whenever possible.
And I would also try to reduce all these copy-pasted code blocks and try to condense their intended behaviours into reusable functions.
Having a quick look at that code I'd detect potential to reduce the length of that code to a third/quater or even less of what it currently is.