Stap 4: voorbeeld
Probeer te uploaden de onderstaande test de code, dan zult u het is zeer eenvoudig en nuttig.
#include <Wire.h>#include <I2C_LCD.h> //For detials of the function useage, please refer to "I2C_LCD User Manual". I2C_LCD LCD; uint8_t I2C_LCD_ADDRESS = 0x51; //Device address setting, default: 0x51 void setup(void) { Wire.begin(); //I2C controler init. } void loop(void) { LCD.CleanAll(WHITE); //Erase all. delay(1000); //Delay for 1s. //8*16 font size, auto new line, black character on white back ground. LCD.FontModeConf(Font_6x8, FM_ANL_AAA, BLACK_BAC); //Set the start coordinate. LCD.CharGotoXY(0, 0); //Print string on I2C_LCD at the start coordinate. LCD.print("Hello, World!"); //Set the start coordinate. LCD.CharGotoXY(0, 10); LCD.print(78); //gives "78" LCD.print('N'); //gives "N" LCD.print(1.23456); //gives "1.23" //Set the start coordinate. LCD.CharGotoXY(0, 20); LCD.print(78, BIN); //gives "1001110" LCD.print(' '); //gives " " LCD.print(78, OCT); //gives "116" LCD.print(' '); //gives " " LCD.print(78, DEC); //gives "78" LCD.print(' '); //gives " " LCD.print(78, HEX); //gives "4E" LCD.print(' '); //gives " " //Set the start coordinate. LCD.CharGotoXY(0, 30); LCD.println(1.23456, 0); //gives "1" LCD.println(1.23456, 2); //gives "1.23" LCD.println(1.23456, 4); //gives "1.2346" LCD.print("Debug with Arduino."); while(1); //Wait for ever. }