LCD12864 - Draw sketch


  • Ameba x 1
  • LCD12864 Module x 1


In this example, we use LCD12864 module to display the sketch drawn in sample code (“012” and a circle).
We need the following library:
For more information about LCD12864:

Please refer to Arduino official tutorial to add .zip library to Ameba:

Open the sample code in “File” -> “Examples” -> “AmebaLCD12864” -> “drawsketch”
Wiring diagram:

Code reference

The sample code draws “0 1 2” and a circle on LCD12864 screen.
After initialization, call Render() to start to draw sketch

use DrawCircle(int x0, int y0, int radius) to draw circle. The first two arguments are the x and y coordinates of the circle, and the third argument is the radius of the circle.


RenderScreenBuffer(int screen) is used to specify the screen part where you want to draw sketch (1 = upper part of the screen, 2 = lower part of the screen)


Draw(bool t, int x, int y) is used to seitch graphics mode.
(t is true means the graphics mode is on, argument ‘x’ and ‘y’ can be any number.)
(t is false means the ASCII mode is on, argument ‘x’ represents the position of the characters (ranging from 0 to 23), and argument ‘y’ is of no use.


setPins(int tRS, int tRW, int tD7, int tD6, int tD5, int tD4, int tD3, int tD2, int tD1, int tD0) specifies data for data lines to draw on LCD screen.
tRS: Register Set
tRW: Read/Write
tD7: Data line 7
tD6: Data line 6
tD5: Data line 5
tD4: Data line 4
tD3: Data line 3
tD2: Data line 2
tD1: Data line 1
tD0: Data line 0

LCDA.setPins(1,0,0,0,1,1,0,0,0,0); //0
LCDA.setPins(1,0,0,0,1,1,0,0,0,1); //1
LCDA.setPins(1,0,0,0,1,1,0,0,1,0); //2
Please confirm that QQ communication software is installed