SKU:RB-05L007A LCD12864液晶搖桿擴展板
來自ALSROBOT WiKi
目錄 |
產品概述
奧松機器人推出的LCD 12864液晶搖桿擴展板采用全新12864G-0088液晶屏為主體顯示器件。此擴展板采用Arduino疊層板設計理念,可直接插接到Arduino UNO、Arduino mega328、Arduino mega2560、Arduino ADK控制器上使用,可以清晰顯示中文、英文、字符、圖片等;板上添加五向微型搖桿,方便實現人機互動;同時本板還具有5個模擬擴展接口和8個字擴展接口;其中各數字接口均分別用黑色、紅色、黃色排針來區(qū)別電源地、電源正極和信號IO管腳;即方便操作又具有防呆的作用;而且擴展接口可連接各種傳感器模塊,如溫度濕度傳感器、三軸加速度計等,是制作顯示互動作品不可獲缺的顯示器。
規(guī)格參數
- 產品名稱:LCD12864液晶搖桿擴展版
- 產品貨號:RB-05L007A
- 工作電壓:3.3V
- 點陣:128x64
- 視窗尺寸:39.8mm x25.5mm
- 顯示顏色:白色背光黑色文字
- 工作溫度:0°C~+85°C
- 數據類型:數字輸入
- 尺寸:70mm x 53mm
接口定義
- S:信號接口
- V:電源正極
- G/GND:電源地
- RST:同Arduino復位接口
- 3V3:同Arduino 3.3V接口
- VCC:同Arduino 5V接口
- VIN:同Arduino VIN接口
使用方法
連接示意圖
如圖所示,將12864液晶搖桿擴展板與 Arduino 控制器連接在一起
例子程序
#define cs_mini12864 2 //片選 低電平片選 #define rst_mini12864 3 //物理重置.低電平有效 #define rs_mini12864 4 //寄存器選擇 1:數據寄存器 0:指令寄存器 #define sck_mini12864 5 //時鐘 #define sda_mini12864 6 //數據 //上面的腳可以自己修改 #define Display 0xAF //顯示開啟 #define Power 0x2F //電源全開 #define VO 0x24 //對比度調節(jié) #define AllPoint 0xA4 //非全屏顯示 #define ADCset 0xA1 //負向,131-4 #define COMset 0xc0 //com0-com63 #define ELECTVO 0x81 //亮度調節(jié) 調節(jié)顏色 不同的模塊需要不同的 ELECTSET #define ELECTSET 0x2a //亮度數值 調節(jié)顏色 不同的模塊需要不同的 數值 #define BIASSET 0xA2 //占空比1/9 unsigned char ao[]={0x00,0x00,0xFC,0x04,0x54,0xE6,0x45,0xF4,0x44,0xE4,0x54,0x04,0xFC,0x00,0x00,0x00, 0x88,0x88,0x4B,0x48,0x29,0x28,0x18,0x0D,0x18,0x28,0x29,0x48,0x4B,0x88,0x88,0x00};/*"奧",0*/ unsigned char song[]={0x10,0x10,0xD0,0xFF,0x90,0x10,0x80,0x60,0x1E,0x00,0xE0,0x07,0x18,0x60,0x80,0x00, 0x04,0x03,0x00,0xFF,0x00,0x03,0x20,0x70,0x2C,0x23,0x20,0x20,0x24,0x38,0x60,0x00};/*"松",1*/ unsigned char ji[]={0x10,0x10,0xD0,0xFF,0x90,0x10,0x00,0xFE,0x02,0x02,0x02,0xFE,0x00,0x00,0x00,0x00, 0x04,0x03,0x00,0xFF,0x00,0x83,0x60,0x1F,0x00,0x00,0x00,0x3F,0x40,0x40,0x78,0x00};/*"機",2*/ unsigned char qi[]={0x80,0x80,0x9E,0x92,0x92,0x92,0x9E,0xE0,0x80,0x9E,0xB2,0xD2,0x92,0x9E,0x80,0x00, 0x08,0x08,0xF4,0x94,0x92,0x92,0xF1,0x00,0x01,0xF2,0x92,0x94,0x94,0xF8,0x08,0x00};/*"器",3*/ unsigned char ren[]={0x00,0x00,0x00,0x00,0x00,0x00,0xC0,0x3F,0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x80,0x40,0x20,0x10,0x0C,0x03,0x00,0x00,0x00,0x03,0x0C,0x10,0x20,0x40,0x80,0x00};/*"人",4*/ void send_8bit_mini12864(unsigned char d) //傳8位數據,高位先傳 { for(int i=0;i<8;i++) //循環(huán)8次,每次發(fā)送1個最高位 { digitalWrite(sck_mini12864,0); //時鐘拉低,一位數據開始 if(d&0x80) //與上10000000,最高位如果是1,就數據位就高 digitalWrite(sda_mini12864,1); else //與上10000000,最高位如果是0,就數據位就低 digitalWrite(sda_mini12864,0); digitalWrite(sck_mini12864,1); //一位數據發(fā)送完畢,時鐘拉高 d<<=1; // d|ddddddd0 拋掉最高位,其余數據左移一位,最低位填0 } } void write_cmd_mini12864(unsigned char cmd) //寫命令 { digitalWrite(cs_mini12864,0); //片選拉低,選中芯片 digitalWrite(rs_mini12864,0); //rs為低,寫入命令 send_8bit_mini12864(cmd); //寫入8位命令 } void write_dat_mini12864(unsigned char dat) //寫數據 { digitalWrite(cs_mini12864,0); //片選拉低,選中芯片 digitalWrite(rs_mini12864,1); //rs為高,寫入數據 send_8bit_mini12864(dat); //寫入8位數據 } void mini12864_cl() //清屏,其實就是把所有的地址全部填成0 { unsigned char x,y; for(y=0;y<8;y++) { write_cmd_mini12864(0xb0+y); write_cmd_mini12864(0x10); write_cmd_mini12864(0x00); for(x=0;x<132;x++) write_dat_mini12864(0); } } void mini12864_Init() //初始化 { pinMode(cs_mini12864,OUTPUT); //設置各個I/O為輸出 pinMode(rst_mini12864,OUTPUT); pinMode(rs_mini12864,OUTPUT); pinMode(sck_mini12864,OUTPUT); pinMode(sda_mini12864,OUTPUT); digitalWrite(cs_mini12864,LOW); digitalWrite(rst_mini12864,LOW); //物理重置 delay(200); digitalWrite(rst_mini12864,HIGH); delay(1000); write_cmd_mini12864(0xe2); //軟件重置 delay(200); //以下為初始設置,具體請參考數據手冊 write_cmd_mini12864(0x24);//對比度 write_cmd_mini12864(0x81);//SET ELECTRONIC VOLUME write_cmd_mini12864(0x20);//set pm: 通過改變這里的數值來改變電壓 write_cmd_mini12864(0x2f);//set power control write_cmd_mini12864(0xa2);//BR=1/9 write_cmd_mini12864(0xa0);//set seg direction write_cmd_mini12864(0xc8);//set com direction write_cmd_mini12864(0x40);//set scroll line //write_cmd(0xa6);//set inverse display a6 off, a7 on //write_cmd(0xa4);//set all pixel on write_cmd_mini12864(0xaf);//開顯示 mini12864_cl(); //清屏 } void mini12864_address(unsigned char page,unsigned char column) { digitalWrite(cs_mini12864,0); //片選拉低,選中芯片 column=column-1; page=page-1; write_cmd_mini12864(0xb0+page); write_cmd_mini12864(((column>>4)&0x0f)+0x10); write_cmd_mini12864(column&0x0f); } void full_dispaly() { int i,j; for(i=0;i<8;i++) { digitalWrite(cs_mini12864,0); //片選拉低,選中芯片 mini12864_address(i+1,0); for(j=0;j<128;j++) { write_dat_mini12864(0xff); } } } void disp_graphic_32X32(unsigned char page,unsigned char column,unsigned char *dp) { unsigned char i,j; digitalWrite(cs_mini12864,0); //片選拉低,選中芯片 for(j=0;j<4;j++) { mini12864_address(page+1,column); for(i=0;i<31;i++) { write_dat_mini12864(*dp); dp++; } } digitalWrite(cs_mini12864,1); //片選拉低,選中芯片 } void display_graphic_16x16(unsigned char page,unsigned char column,unsigned char *dp) { unsigned char i,j; digitalWrite(cs_mini12864,0); //片選拉低,選中芯片 for(j=0;j<2;j++) { mini12864_address(page+j,column); for (i=0;i<16;i++) { write_dat_mini12864(*dp); /*寫數據到LCD,每寫完一個8 位的數據后列地址自動加1*/ dp++; } } digitalWrite(cs_mini12864,1); //片選拉低,選中芯片 } void display_graphic_8x16(unsigned char page,unsigned char column,unsigned char *dp) { unsigned char i,j; digitalWrite(cs_mini12864,0); //片選拉低,選中芯片 for(j=0;j<2;j++) { mini12864_address(page+j,column); for (i=0;i<8;i++) { write_dat_mini12864(*dp); /*寫數據到LCD,每寫完一個8 位的數據后列地址自動加1*/ dp++; } } digitalWrite(cs_mini12864,1); //片選拉低,選中芯片 } void setup() { mini12864_Init(); //初始化液晶 } void loop() { full_dispaly(); delay(2000); mini12864_cl(); //清屏 display_graphic_16x16(4,24,ao); display_graphic_16x16(4,24+16,song); display_graphic_16x16(4,24+32,ji); display_graphic_16x16(4,24+48,qi); display_graphic_16x16(4,24+64,ren); delay(5000); } }
程序效果
程序下載到 Arduino 控制器之后就可以顯示出漢字“奧松機器人”了。
[ Arduino LCD 12864液晶搖桿擴展板]
資料下載
- 產品資料
下載鏈接: https://pan.baidu.com/s/1amSPthA7Q4XAOIz8ZltMSg 提取碼:cnad
- 產品購買鏈接:http://lifestyle201.com/goods-744.html
- 奧松機器人技術論壇:http://www.makerspace.cn