RB-05L007A LCD12864液晶搖桿擴(kuò)展板

來自ALSROBOT WiKi
跳轉(zhuǎn)至: 導(dǎo)航搜索
05L007A01.png

目錄

產(chǎn)品概述

奧松機(jī)器人推出的LCD 12864液晶搖桿擴(kuò)展板采用全新12864G-0088液晶屏為主體顯示器件。此擴(kuò)展板采用Arduino疊層板設(shè)計(jì)理念,可直接插接到Arduino UNO、Arduino mega328、Arduino mega2560、Arduino ADK控制器上使用,可以清晰顯示中文、英文、字符、圖片等;板上添加五向微型搖桿,方便實(shí)現(xiàn)人機(jī)互動;同時本板還具有5個模擬擴(kuò)展接口和8個字?jǐn)U展接口;其中各數(shù)字接口均分別用黑色、紅色、黃色排針來區(qū)別電源地、電源正極和信號IO管腳;即方便操作又具有防呆的作用;而且擴(kuò)展接口可連接各種傳感器模塊,如溫度濕度傳感器、三軸加速度計(jì)等,是制作顯示互動作品不可獲缺的顯示器。

規(guī)格參數(shù)

  1. 產(chǎn)品名稱:LCD12864液晶搖桿擴(kuò)展版
  2. 產(chǎn)品貨號:RB-05L007A
  3. 工作電壓:3.3V
  4. 點(diǎn)陣:128x64
  5. 視窗尺寸:39.8mm x25.5mm
  6. 顯示顏色:白色背光黑色文字
  7. 工作溫度:0°C~+85°C
  8. 數(shù)據(jù)類型:數(shù)字輸入
  9. 尺寸:70mm x 53mm

接口定義

  1. S:信號接口
  2. V:電源正極
  3. G/GND:電源地
  4. RST:同Arduino復(fù)位接口
  5. 3V3:同Arduino 3.3V接口
  6. VCC:同Arduino 5V接口
  7. VIN:同Arduino VIN接口

使用方法

連接示意圖

如圖所示,將12864液晶搖桿擴(kuò)展板與 Arduino 控制器連接在一起

05L007A021.png
05L007A03.png

例子程序

小車安裝完成后,就可以進(jìn)行基本功能的調(diào)試,將下列程序上傳到 Carduino 控制器中

將下載到的壓縮文件解壓到到 Arduino IDE 軟件的 libraries 文件中(·····\arduino-1.7.6\libraries),啟動 Arduino IDE 選擇文件 -- 示例 -- RB-05L007A_LCD12864_Joystick_Shield_v3.0-master -- 打開 example 中的相應(yīng)例子程序,上傳到 Arduino UNO 控制器中,就可以實(shí)現(xiàn)代碼測試。操作方法下圖所示:
1、解壓過程

05L007A10.png
05L007A11.png

2、打開示例程序

05L007A12.png
05L007A13.png
#define cs_mini12864 2   //片選 低電平片選
#define rst_mini12864 3 //物理重置.低電平有效
#define rs_mini12864 4   //寄存器選擇 1:數(shù)據(jù)寄存器 0:指令寄存器
#define sck_mini12864 5 //時鐘
#define sda_mini12864 6 //數(shù)據(jù)
//上面的腳可以自己修改
#define  Display  0xAF     //顯示開啟
#define  Power    0x2F           //電源全開
#define  VO       0x24     //對比度調(diào)節(jié)             
#define  AllPoint 0xA4           //非全屏顯示
#define  ADCset   0xA1            //負(fù)向,131-4
#define  COMset   0xc0            //com0-com63
#define  ELECTVO  0x81     //亮度調(diào)節(jié)         調(diào)節(jié)顏色         不同的模塊需要不同的  ELECTSET
#define  ELECTSET 0x2a           //亮度數(shù)值         調(diào)節(jié)顏色         不同的模塊需要不同的        數(shù)值
#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};/*"機(jī)",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位數(shù)據(jù),高位先傳
{
        for(int i=0;i<8;i++)                    //循環(huán)8次,每次發(fā)送1個最高位
        {
                digitalWrite(sck_mini12864,0);       //時鐘拉低,一位數(shù)據(jù)開始
                if(d&0x80)                          //與上10000000,最高位如果是1,就數(shù)據(jù)位就高
                        digitalWrite(sda_mini12864,1);
                else                                //與上10000000,最高位如果是0,就數(shù)據(jù)位就低
                        digitalWrite(sda_mini12864,0);
                digitalWrite(sck_mini12864,1);       //一位數(shù)據(jù)發(fā)送完畢,時鐘拉高
                d<<=1;                              // d|ddddddd0    拋掉最高位,其余數(shù)據(jù)左移一位,最低位填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)  //寫數(shù)據(jù)
{
        digitalWrite(cs_mini12864,0); //片選拉低,選中芯片
        digitalWrite(rs_mini12864,1); //rs為高,寫入數(shù)據(jù)
        send_8bit_mini12864(dat);          //寫入8位數(shù)據(jù)
}

void mini12864_cl()         //清屏,其實(shí)就是把所有的地址全部填成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);   //設(shè)置各個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);
 
//以下為初始設(shè)置,具體請參考數(shù)據(jù)手冊
 
  write_cmd_mini12864(0x24);//對比度
  write_cmd_mini12864(0x81);//SET ELECTRONIC VOLUME
  write_cmd_mini12864(0x20);//set pm: 通過改變這里的數(shù)值來改變電壓 
  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); /*寫數(shù)據(jù)到LCD,每寫完一個8 位的數(shù)據(jù)后列地址自動加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); /*寫數(shù)據(jù)到LCD,每寫完一個8 位的數(shù)據(jù)后列地址自動加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 控制器之后就可以顯示出漢字“奧松機(jī)器人”了。

產(chǎn)品相關(guān)推薦

Erweima.png

產(chǎn)品購買地址

Arduino LCD 12864液晶搖桿擴(kuò)展板

周邊產(chǎn)品推薦

Arduino 8位靜態(tài)數(shù)碼管 掃描顯示器 SPI LED 數(shù)碼管
Arduino 8*8點(diǎn)陣模塊 單色 8X8 LED Matrix Module
Carduino UNO R3 控制器

相關(guān)學(xué)習(xí)資料

Arduino 條形LED模塊測評
奧松機(jī)器人技術(shù)論壇