User Tools

Site Tools

한국어

faduino:interfacing_with_the_clcd:index

Interfacing with the CLCD

The CLCD module can be connected to the FADUINO via RS-232 or I2C.

RS-232

Connect to the FA-DUINO as shown below. Set both DIP switches on the CLCD module to the ON position and use a baud rate of 115200.

Upload the following program to the FA-DUINO.

void setup() 
{
   Serial1.begin(115200);
   clear();
   delay(20);
 
   locate(0,0);
   Serial1.print("=== CLCD_TEST ===");
 
   delay(100);
 
   locate(2,1);
   Serial1.print(" FA-DUINO-12RA ");
 
   delay(100);
}
 
void loop()
{
}
 
 
// Clear the screen
void clear()
{ 
   Serial1.write(0x1b); Serial1.write(0x43); 
}
 
// Set the cursor location
void locate(unsigned char x, unsigned char y)
{ 
   Serial1.write(0x1b);
   Serial1.write(0x4C);
   Serial1.write(x); 
   Serial1.write(y); 
} 

I2C (FA-DUINO-18TA / 32TA)

For this example, set the dip switches on the LCD module to the OFF position, and set the slave address to 0.

Connecting to the FA-DUINO-18TA

Connecting to the FA-DUINO-32TA

Upload the following program to the FA-DUINO.

#include    <Wire.h>
#define     ADDR_CLCD             0
 
unsigned char   locate_x;
unsigned char   locate_y;
 
void clcd_clear             ();
void clcd_cursor_visible    (bool enable);
void clcd_backLight_enable  (bool enable);
void clcd_print             (String value);
void clcd_locate            (unsigned char x, unsigned char y);
 
void setup() 
{
  Wire.begin();
  Wire.setClock(500000);
  clcd_clear();
  clcd_cursor_visible(false);
  clcd_backLight_enable(true);
  clcd_locate(0,4);
  clcd_print("COMFILE_TECH");
  clcd_locate(2,5);
  clcd_print("0123456789");
}
 
void loop() 
{
}
 
void clcd_clear()
{
  unsigned char tmp_buf[] = {0x1b,0x43};
  Wire.beginTransmission(ADDR_CLCD);
  Wire.write(tmp_buf,2);
  Wire.endTransmission();
  delay(200);
}
 
void clcd_cursor_visible(bool enable)
{
  unsigned char tmp_buf[] = {0x1b,enable == true ? 0x53 : 0x73};
  Wire.beginTransmission(ADDR_CLCD);
  Wire.write(tmp_buf,2);
  Wire.endTransmission();
}
 
void clcd_backLight_enable(bool enable)
{
  unsigned char tmp_buf[] = {0x1b,enable == true ? 0x42 : 0x62};
  Wire.beginTransmission(ADDR_CLCD);
  Wire.write(tmp_buf,2);
  Wire.endTransmission();
}
 
void clcd_locate(unsigned char x, unsigned char y)
{
  locate_x = x;
  locate_y = y;
}
 
void clcd_print(String value)
{
  unsigned char tmp_buf[] = {0x1b,0x4b,locate_y,locate_x,locate_y,locate_x};
  Wire.beginTransmission(ADDR_CLCD);
  Wire.write(tmp_buf,6);
  Wire.write(value.c_str());
  Wire.write(0);
  Wire.endTransmission();
}
faduino/interfacing_with_the_clcd/index.txt · Last modified: 2020/03/04 17:44 by COMFILE Technology