Programming the Arduino
Step 1: Install the MatesController library using Arduino’s Library Manager.
Step 2: Include MatesController.h and SoftwareSerial.h to your project.
Step 3: Create a Software Serial instance named matesSerial and declare Serial as debugSerial.
Step 4: Create a MatesController instance named mates setting matesSerial for TIMI and debugSerial for Arduino’s Serial Monitor.
This will initialize the MatesController instance to the default reset pin 4 using a LOW pulse.
Step 5: (Optional) Create a function for toggling the built-in LED of the Arduino board. This can be used for debugging or showing errors if the Serial monitor can’t be used.
Step 6: (Optional) At the beginning of the setup function, set the built-in LED pin to OUTPUT and set it to LOW.
Step 7: To start using the MatesController instance, use the begin function
As shown, the Serial objects for both TIMI and Serial Monitor needs to be initialized before the mates instance.
Note: Debug streams needs to be setup beforehand. Serial for the BBM module also needs to be setup initially if it is not a HardwareSerial (ex. Software Serial, Alt Soft Serial)
Step 8: (Optional) The begin function can be enclosed in an if condition to handle initialization errors.
Step 9: Create supporting functions for parse hex string to bytes
Step 10: In the loop function, the values are read from Serial monitor and sent to TIMI as necessary.
As shown, the code starts by reading the Serial monitor for user input. If there is any, the code attempts to parse the hex string to an 8-bit array. If successful, the PrintArea is cleared and the hex bytes are printed sequentially.