I was going to suggest you look at intigrating an existing arduino library such as this one:
or one of the others available via google search.
probably trying to follow some of the existing examples such as this:
https://xod.io/docs/guide/wrapping-arduino-libraries/
I’ve only been using XOD a week, and have had my own issues attempting to integrate what I thought was a “simple” bit of code into XOD and failing … https://github.com/NicksonYap/digitalWriteFast