Simulated Hex Values from Arduino
Introduction
Arduino's are very common microcontroller boards used to study and design programmable electronics. It is often used with multiple peripherals such as buttons, sliders, sensors and motors.
Together with a TIMI acting as a small fancy display, Arduino boards become a lot more powerful and interesting to use in prototyping.
This project showcases a TIMI-96 module controlled by an Arduino Uno to print simulated 8-bit values in hexadecimal form. This also shows how to clear the PrintArea and change the print color.
Requirements
To proceed with the project, the following are required.
Hardware
- TIMI-96
- Mates Programmer
- USB Type A to microUSB cable (for the Mates Programmer)
- USB Type A to Type B cable (for the Arduino, replace as necessary)
- Connecting Wires
- Arduino Uno
- Breadboard
Software
Graphics Design
Step 1: Open Mates Studio and create a Commander project for TIMI-96 with Reversed Landscape orientation
Step 2: Browse the library for appropriate page designs. For this project, 6-Line Hex Print Area page under Notifications category was used.
Step 3: After finalizing the design, connect TIMI-96 to your computer
Step 4: Upload the project to the appropriate COM port
Step 5: When prompted, click Proceed to continue with upload.
Note
It is recommended that the graphics design is finalized before moving to the next steps when working on a project*
Programming the Arduino
Step 1: Install the MatesController library using Arduino’s Library Manager.
Step 2: Include MatesController.h to your project.
Step 3: Create a MatesController instance named mates.
This will initialize the MatesController instance to the default reset pin 4 using a LOW pulse.
Step 4: (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.
int errLedStatus = LOW;
void ErrorLed_Toggle() {
errLedStatus = ~errLedStatus;
digitalWrite(LED_BUILTIN, errLedStatus);
}
Step 5: (Optional) At the beginning of the setup function, set the built-in LED pin to OUTPUT and set it to LOW.
Step 6: To start using the MatesController instance, use the begin
function
This will initialize the Serial UART at the default baudrate of 9600
Step 7: (Optional) The begin
function can be enclosed in an if condition to handle initialization errors.
if (!mates.begin()) {
// Display didn't send ready signal in time
while (1) {
ErrorLed_Toggle();
delay(100);
}
}
Step 8: In order to change the print colors, an array of 16-bit (RGB565) colors can be prepared.
const int16_t colors[] = {
(int16_t) 0xFFFF, (int16_t) 0xF800, (int16_t) 0x07E0, (int16_t) 0x001F,
(int16_t) 0x07FF, (int16_t) 0xF81F, (int16_t) 0xFFE0, (int16_t) 0x39FF
};
Step 9: In the loop function, the values are simulated and sent to TIMI as necessary.
void loop() {
static int8_t val = 0;
static int8_t ctr = 0;
if (ctr >= 42) {
mates.clearPrintArea(0);
ctr = 0;
}
mates.setPrintAreaColor(0, colors[ctr % 8]);
mates.appendToPrintArea(0, &val, 1);
ctr++;
val++;
delay(100);
}
As shown, the code utilizes two variables for value and print counter that is incremented at the end of the loop. By counting the number of times a byte was printed, the PrintArea can be cleared when full. It is also shown that the print color is changed depending on the print count.
Running the Project
After designing the user interface for TIMI and writing code for the Arduino and programming them, it is time to connect the devices together. Follow the diagram below for the connection between TIMI and Arduino.
Finally, supply power to the Arduino and observe the behavior of the project.
Downloadable Resources
The Mates Studio – Commander project and Arduino sketch are included in the MatesController library.
The Commander project is available under the extras folder of the library. You can find it in (if the library was installed using Arduino Library Manager):
C:\Users\%USERNAME%\Documents\Arduino\libraries\MatesController\extras\Print Hex Values.mates
Here are the links to the software applications, libraries and completed project files.