Another possible approach might be:
- Add a MATLAB Function block to the model.
- Port the logic portion of the Arduino code to MATLAB code
- Use the coder.ceval function to call standard built-in Arduino functions, such as pulseIn().
- Use pinMode(), digitalRead(), digitalWrite() (avoid Arduino Digital Input/Output blocks, which do not have pinMode)
- Adjust the timing of code in MATLAB Function block to fit within the timing of the model.
This would require a fair amount of experimentation.