This product is for simple user interface. It has 20 by 4 English LCD and 5 keys.
This product connects using RS232C. Use either CH1 or CH2 of CFMEGA2. Connect RX, TX so that they are crossed, and connect SG.
If you send a string via RS232C, it will be displayed on the LCD.
LCD control commands are in the format of sending an ESC code (HEX 1B) as the first, sending one English letter to instruct an action, and then sending various arguments required for it.
Special command | Command code | Description | Transmission example (hexadecimal) |
---|---|---|---|
Character Cursor On | ESC S | Turns the cursor on. | 1B 53 |
Character Cursor Off | ESC s | Turns the cursor off. | 1B 73 |
Clear LCD | ESC C | Clears the entire screen. After using this command, you must send the following command about 20mS later. | 1B 43 |
Backlight ON/OFF | ESC BL # | Turns the backlight on or off. # is 0 for OFF, 1 for ON | 1B 42 4C 01 |
Set Coordinates | ESC L X Y | Moves the display point to the X Y position. | 1B 4C 00 00 |
Set Buzzer ON / OFF | ESC Z # | Determines whether to generate a BEEP sound when pressing the switch. #=0 for OFF, #=1 for On | 1B 5A 01 |
When a key is pressed, 1 byte of the corresponding key code is received. Keycodes are 1~5 from the left.
This product is designed to be used in the following way.
Here is an operational example:
int mode = 0; void setup() { Serial1.begin(115200); mode_display_proc(); } void mode_display_proc() { switch(mode) { case 0: uif_clear(); uif_light(1); uif_buzzer(1); uif_locate(0,0); Serial1.print(" AB CONTROL SYSTEM"); uif_locate(0,3); Serial1.print("SETUP"); break; case 1: uif_clear(); uif_locate(0,0); Serial1.print("1.MAIN TANK TEMP.>"); uif_locate(9,3); Serial1.print("+ -"); break; case 2: uif_clear(); uif_locate(0,0); Serial1.print("<2.MAIN TANK MIX>"); uif_locate(0,3); Serial1.print("AUTO ON OFF"); break; case 3: uif_clear(); uif_locate(0,0); Serial1.print("3.END OF MENU"); uif_locate(0,3); Serial1.print("EXIT"); break; } } void keyin_proc() { char inChar = (char)Serial1.read(); switch(mode) { case 0: if (inChar==2) { mode = 1; mode_display_proc(); } break; case 1: if (inChar==5) { mode = 2; mode_display_proc(); } break; case 2: if (inChar==1) { mode = 1; mode_display_proc(); } if (inChar==5) { mode = 3; mode_display_proc(); } break; case 3: if (inChar==1) { mode = 2; mode_display_proc(); } if (inChar==2) { mode = 0; mode_display_proc(); } break; } } void loop() { while (Serial1.available()>0) { keyin_proc(); } } void uif_clear() { Serial1.write(0x1b); Serial1.write(0x43); delay(50); } void uif_light(unsigned char on_off) { Serial1.write(0x1b);Serial1.write(0x42);Serial1.write(0x4c); Serial1.write(on_off); } void uif_locate(unsigned char x, unsigned char y) { Serial1.write(0x1b);Serial1.write(0x4C);Serial1.write(x); Serial1.write(y); delay(50); } void uif_buzzer(unsigned char on_off) { Serial1.write(0x1b);Serial1.write(0x5a);Serial1.write(on_off); }