導航:首頁 > 操作系統 > 單片機顯示圖形程序

單片機顯示圖形程序

發布時間:2023-09-16 12:41:54

❶ 51單片機顯示時間的流程圖怎麼畫

51單片機顯示時間的流程圖畫步驟。
1、首先畫出51單片機流程圖框架。
2、其次添加流程圖細節,完善框架。最後寫上文字標題即可畫出單片機顯示時間的流程圖。51單片機是對所有兼容Intel8031指令系統的單片機的統稱。

❷ 單片機秒錶計時器c語言程序圖 需要圖和程序

#include<reg51.h> // 時鍾與秒錶

#define uchar unsigned char

#define uint unsigned int

sbit qingling=P1^0; //清零

sbit tiaofen=P1^1; //調分

sbit tiaoshi=P1^2; //調時

sbit sounder=P1^7; //naozhong

uint a,b;

uchar hour,minu,sec, //時鍾

hour0,minu0,sec0, //秒錶

hour1,minu1,sec1;

h1,h2,m1,m2,s1,s2, //顯示位

k,s; //狀態轉換標志

uchar code select[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};

uchar code table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};

/*****************函數聲明***********************/

void keyscan();

void init();

void delay(uchar z);

void display(uchar,uchar,uchar);

void sounde();

/*****************主函數*************************/

void main()

{

init();

while(1)

{

while(TR1)

{

keyscan(); // 掃描函數

while(s==1) // s是狀態標志,當s=0時,鬧鍾取消。s=1時,設定鬧鍾時間

//(也是通過調時,調分函數);

{ //s=2時,鬧鍾工作,時間與設定時刻一致時,鬧鍾響

// (一分鍾後自動關閉,可手動關閉)。再次切換,s=0.

keyscan(); //s狀態切換(0-》1-》2-》0)通過外部中斷1實現。

display(hour1,minu1,sec1); //鬧鍾時刻顯示

}

display(hour0,minu0,sec0);//時鍾表顯示

while(k) /*k是秒錶狀態(0-》1-》2-》0)通過外部中斷0實現。

0秒錶關;1秒錶從零計時;2秒錶停,顯示計時時間*/

{

display(hour,minu,sec); //秒錶顯示

}

}

}

}

/*****************初始化函數***********************/

void init()

{

a=0;

b=0;

k=0;

s=0;

hour0=0;

minu0=0;

sec0=0;

hour=0;

minu=0;

sec=0;

hour1=0;

minu1=0;

sec1=0;

TMOD=0x11; //定時器0,1工作於方式1;賦初值

TH0=(65536-5000)/256;

TL0=(65536-5000)%256;

TH1=(65536-50000)/256;

TL1=(65536-50000)%256;

EA=1;

EX0=1; //秒錶中斷

EX1=1; //鬧鍾設定中斷

ET0=1;

ET1=1;

IT0=1; //邊沿觸發方式

IT1=1;

PX0=1;

PX1=1;

TR0=0; //初始,秒錶不工作

TR1=1; //時鍾一開始工作

}

/*****************定時器0中斷*************/

void timer0_int() interrupt 1 //秒錶

{

TH0=(65536-5000)/256;

TL0=(65536-5000)%256;

a++;

if(a==2)

{

a=0;

sec++;

if(sec==100)

{

sec=0; //毫秒級

minu++;

if(minu==60)

{

minu=0; //秒

hour++;

if(hour==60) //分

{

hour=0;

}

}

}

}

}

/*************外部中斷0中斷函數************/

void ex0_int() interrupt 0

{

k++;

if(k==3)

k=0;

if(k==1)

{

TR0=~TR0;

if(TR0==1)

{

hour=0;

minu=0;

sec=0;

}

}

if(k==2)

{

TR0=~TR0;

}

}

/*************外部中斷1中斷函數************/

void ex1_int() interrupt 2

{

s++;

if(s==3)

s=0;

}

/*************定時器1中斷****************/

void timer1_int() interrupt 3 //控制時鍾工作

{

TH1=(65536-50000)/256;

TL1=(65536-50000)%256;

if(s==2)

{

if(hour1==hour0 && minu0==minu1)

sounde();

}

b++;

if(b==20)

{

b=0;

sec0++;

if(sec0==60)

{

sec0=0;

minu0++;

if(minu0==60)

{

minu0=0;

hour0++;

if(hour0==24)

hour0=0;

}

}

}

}

/*************鍵盤掃描****************/

void keyscan()

{

if(s==1)

{

if(qingling==0)

{

delay(10);

if(qingling==0)

{

sec1=0;

minu1=0;

hour1=0;

}

}

if(tiaofen==0)

{

delay(10);

if(tiaofen==0)

{

minu1++;

if(minu1==60)

{

minu1=0;

}

while(!tiaofen);

}

}

if(tiaoshi==0)

{

hour1++;

if(hour1==24)

{

hour1=0;

}

while(!tiaoshi);

}

}

else //調整時鍾時間

{

if(qingling==0)

{

delay(10);

if(qingling==0)

{

sec0=0;

minu0=0;

hour0=0;

}

}

if(tiaofen==0)

{

delay(10);

if(tiaofen==0)

{

minu0++;

if(minu0==60)

{

minu0=0;

}

while(!tiaofen);

}

}

if(tiaoshi==0)

{

hour0++;

if(hour0==24)

{

hour0=0;

}

while(!tiaoshi);

}

}

}

/*************顯示函數****************/

void display(uchar hour,uchar minu,uchar sec)

{

h1=hour/10;

h2=hour%10;

m1=minu/10;

m2=minu%10;

s1=sec/10;

s2=sec%10;

P0=0xff;

P2=table[h1];

P0=select[7];

delay(5);

P0=0xff;

P2=table[h2];

P0=select[6];

delay(5);

P0=0xff;

P2=0x40;;

P0=select[5];

delay(5);

P0=0xff;

P2=table[m1];

P0=select[4];

delay(5);

P0=0xff;

P2=table[m2];

P0=select[3];

delay(5);

P0=0xff;

P2=0x40;

P0=select[2];

delay(5);

P0=0xff;

P2=table[s1];

P0=select[1];

delay(5);

P0=0xff;

P2=table[s2];

P0=select[0];

delay(5);

}

/*************鬧鍾函數****************/

void sounde()

{

sounder=~sounder;

}

/*************延時函數****************/

void delay(uchar z)

{

int x,y;

for(x=z;x>0;x--)

for(y=110;y>0;y--);

}

❸ 單片機的課程設計——在8*8點陣顯示圖形

這個問題不是很難!
我的理解是樓主可能只用單片機和點陣模塊來實現,這需要單片現來做動態掃描。
首先需要你把點陣上要顯示圖形的代碼寫出來,即每種圖形每行顯示的數據,每個圖形有8行數據,即佔8個位元組的空間!
如果樓主用51單片機來實現的話,可以使用P0口輸出行數據,P1口作為點陣的行掃描控制。
其次要用按鍵控制,只需你把每種圖形以不同的表存起來,再做一個按鍵掃描程序,當檢測到有鍵按下時,把動態掃描的表頭地址更換即可!

❹ 單片機,寫了一個12864lcd(帶字型檔)的圖片顯示程序,但是實現不了,求幫助

你要顯示的是圖片的話,就要用到擴充指令,lcd_init是基本指令,
write_cmd(0x36);
write_cmd(0x3E);
write_cmd(0x01);
還有你display_bmp()程序中下半屏的循環顯示碼錯字了
for(i=0;i<0;i++)應該是
for(i=0;i<32;i++)

❺ 單片機led顯示c程序

電路圖如下:

#include<reg52.h>

#defineuintunsignedint

#defineucharunsignedchar

sbitan=P2^6;

sbitwei=P2^7;

ucharcodedigit[6]={0xf9,0xa4,0xb0,0x99,0x92,0X82};

voiddelay(xms)

{

uinti,j;

for(i=xms;i>0;i--)

for(j=110;j>0;j--);

}

voidmain()

{

while(1)

{

wei=1;

P0=0x01;

wei=0;

an=1;

P0=digit[0];

an=0;

delay(500);

wei=1;

P0=0x02;

wei=0;

an=1;

P0=digit[1];

an=0;

delay(500);

wei=1;

P0=0x04;

wei=0;

an=1;

P0=digit[2];

an=0;

delay(500);

wei=1;

P0=0x08;

wei=0;

an=1;

P0=digit[3];

an=0;

delay(500);

wei=1;

P0=0x10;

wei=0;

an=1;

P0=digit[4];

an=0;

delay(500);

wei=1;

P0=0x20;

wei=0;

an=1;

P0=digit[5];

an=0;

delay(500);

}

}

❻ 20分!給個51單片機圖像液晶程序

#include <reg52.h>

#define uint unsigned int
#define uchar unsigned char
#define x1 0x80
#define x2 0x88
#define y 0x80
#define comm 0
#define dat 1

sbit cs = P0^0;
sbit std = P0^1;
sbit sclk = P0^2;
sbit psb = P0^3; //H=並口; L=串口;
sbit rst = P0^4; //Reset Signal 低電平有效

void wr_lcd (uchar dat_comm,uchar content);
void delay (uint us);

uchar code tab1[]={
"本系列中文模塊內"
"任意位置反白顯示"
"置二級字型檔,可在"
"使用更方便更靈活"
};

uchar code tab31[]={
"金鵬科技有限公司"
"Golden Palm TECH"
};
uchar code tab32[]={
/*-- 調入了一幅圖像:F:\梁\畫圖\HOCO12832.bmp --*/
/*-- 寬度x高度=128x32 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1E,0x00,0x00,0x00,0x00,0x00,0x07,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x7F,0x80,0x00,0x00,0x00,0x00,0x18,0x0C,0x00,0x00,0x01,0x00,0x00,0x00,0x00,
0x01,0xFF,0x80,0x00,0x00,0x00,0x00,0x20,0x00,0x00,0x00,0x13,0x10,0x03,0xFE,0x00,
0x03,0xFF,0xC0,0x00,0x00,0x00,0x00,0x58,0x00,0x00,0x00,0x3F,0x30,0x1F,0xFF,0xC0,
0x03,0xFF,0xE0,0x00,0x00,0x00,0x00,0x8C,0x03,0xF0,0x00,0x7F,0xE0,0x7C,0x01,0xE0,
0x03,0xFF,0xF0,0x00,0x00,0x00,0x01,0x36,0x06,0xC0,0x00,0x5F,0xC0,0xFF,0xFC,0x60,
0x01,0xFF,0xF0,0x00,0x00,0x00,0x02,0x1B,0x0F,0x80,0x00,0xFF,0x01,0xFE,0x0F,0x30,
0x00,0xEF,0xF0,0x00,0x00,0x00,0x02,0x6D,0x9F,0x00,0x00,0x3E,0x03,0xFF,0xF1,0x90,
0x00,0xFF,0xF8,0x00,0x00,0x00,0x04,0x36,0xFE,0x00,0x01,0xFF,0x07,0xFF,0xFC,0x90,
0x00,0xEF,0xFF,0xFF,0x80,0x00,0x04,0xDB,0x7E,0x00,0x03,0xFF,0x87,0xFF,0xFC,0xD0,
0x00,0x0F,0xFF,0xFF,0xC0,0x00,0x04,0x6D,0xFC,0x00,0x07,0xFF,0x8F,0xFF,0xFE,0x50,
0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x36,0xFC,0x10,0x07,0xFF,0x8F,0xFF,0xFE,0x90,
0x00,0x0F,0xFF,0xFF,0xE0,0x00,0x04,0x1B,0xF8,0x10,0x07,0xFF,0xCF,0xFF,0xFE,0x80,
0x00,0x0F,0xFF,0xFF,0xF0,0x00,0x04,0x0F,0xF8,0x10,0x07,0xFF,0xFF,0xFF,0xFA,0x00,
0x00,0x07,0xFF,0xFF,0xF0,0x00,0x04,0x07,0xF0,0x10,0x07,0xFF,0xFF,0xFF,0xFA,0x00,
0x00,0xFF,0xFF,0xFF,0xF8,0x00,0x02,0x03,0xF0,0x20,0x07,0xFF,0xFF,0xFF,0xBA,0x00,
0x00,0xFD,0xFF,0xFF,0xFC,0x00,0x02,0x03,0xF0,0x20,0x03,0xFF,0xFF,0xDF,0xB8,0x00,
0x00,0xC1,0xC0,0x3F,0xFC,0x00,0x01,0x01,0xE0,0x40,0x00,0xFF,0xFF,0xDF,0xB0,0x00,
0x00,0x81,0xC0,0x3F,0xCE,0x00,0x00,0x81,0xE0,0x80,0x00,0x7F,0xFF,0xDF,0xA0,0x00,
0x00,0x81,0x80,0x1D,0xCF,0x00,0x00,0x41,0xE1,0x00,0x00,0x3F,0xFF,0x9B,0x00,0x00,
0x01,0x83,0x80,0x1F,0xC7,0x80,0x00,0x21,0xE2,0x00,0x00,0x1F,0xFD,0xB6,0x00,0x00,
0x01,0xC3,0x00,0x0E,0xE6,0x80,0x00,0x19,0xEC,0x00,0x00,0x07,0xFE,0x20,0x00,0x00,
0x00,0xC3,0x00,0x07,0x67,0x40,0x00,0x07,0xF0,0x00,0x00,0x03,0x3E,0x00,0x00,0x00,
0x00,0x02,0x00,0x03,0xE7,0xA0,0x00,0x00,0x00,0x00,0x00,0x02,0x8E,0x00,0x00,0x00,
0x00,0x06,0x00,0x03,0x83,0x00,0x00,0x00,0x00,0x00,0x00,0x02,0x03,0x00,0x00,0x00,
0x00,0x06,0x00,0x07,0x03,0x00,0x77,0x46,0x74,0x24,0x80,0x06,0x04,0x00,0x00,0x00,
0x00,0x1C,0x00,0x06,0x00,0x00,0x55,0x45,0x54,0x57,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x1C,0x00,0x0E,0x00,0x00,0x45,0x45,0x74,0x57,0x80,0x08,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1C,0x00,0x00,0x55,0x45,0x44,0x74,0x80,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x38,0x00,0x00,0x77,0x76,0x47,0x54,0x80,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x10,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

uchar code tab5[]={
/*-- 調入了一幅圖像:F:\梁\畫圖\COCK.bmp --*/
/*-- 寬度x高度=128x64 --*/
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x80,0x00,0x0F,0xFF,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0C,0x43,0x01,0x80,0x00,0x7F,0xFF,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x19,0xFF,0x07,0x00,0x07,0xFF,0xFF,0xFE,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0x3F,0xFC,0x1E,0x00,0x1F,0xFF,0xFF,0xFF,0x80,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xBF,0xFF,0xFC,0x00,0x7F,0xFC,0x00,0x7F,0xC0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xFF,0xF0,0x00,0xFF,0xC0,0x00,0x0F,0xE0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xFF,0xE0,0x03,0xFF,0xFF,0xFC,0x01,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xDF,0xFF,0xC0,0x07,0xFF,0xFF,0xFF,0x80,0xF0,0x00,0x00,0x00,
0x00,0x00,0x00,0x03,0xFF,0xFF,0x00,0x0F,0xFF,0xFF,0xFF,0xE0,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xF8,0x00,0x1F,0xFF,0xF0,0x03,0xF8,0x38,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xE0,0x00,0x3F,0xFF,0xFF,0xC0,0x7C,0x18,0x00,0x00,0x00,
0x00,0x00,0x00,0x04,0x7F,0xF0,0x00,0x3F,0xFF,0xFF,0xF8,0x1E,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xF8,0x00,0x7F,0xFF,0xFF,0xFE,0x0F,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xFF,0xFC,0x00,0xFF,0xFF,0xFF,0xFF,0x87,0x08,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0xFF,0xFE,0x00,0xFF,0xFF,0xFF,0xFF,0x83,0x88,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xC3,0x88,0x00,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFF,0xFE,0x01,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xE1,0x88,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF1,0x88,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFE,0x03,0xFF,0xFF,0xFF,0xFF,0xF3,0x08,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0x07,0xFF,0xFF,0xFF,0xFF,0xF2,0x10,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0x8F,0xFF,0xFF,0xFF,0xFF,0xF0,0x20,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xF0,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0xFF,0xFF,0xFE,0xFF,0x70,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0x7F,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0xFF,0xBF,0xFF,0x7F,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x7E,0x20,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFF,0xFF,0xDF,0xFF,0x3E,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x1F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFF,0x3C,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xFF,0xFF,0xFF,0xFF,0xCF,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x07,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x38,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x01,0xFF,0xFF,0xFF,0xFF,0x8F,0xFE,0x30,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0xFF,0xFF,0xFF,0xFF,0x1F,0x7C,0x20,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x7F,0xFF,0xFF,0xFE,0x1E,0x78,0x00,0x40,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x3F,0xFF,0xFF,0xFE,0x1E,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x1F,0xFF,0xFF,0xDA,0x3C,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x07,0xFF,0xFF,0xF2,0x30,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0xFF,0xFF,0xF1,0x20,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xFE,0x7F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x7C,0x3F,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x78,0x1F,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x72,0x07,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x70,0x00,0xE0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x78,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x60,0x00,0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0xC0,0x03,0xF0,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x40,0x04,0xD8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x01,0x00,0x01,0x08,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x0C,0x02,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x02,0x40,0x04,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x0C,0x48,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x38,0x41,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x0F,0xE2,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x40,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};

/*------------------初始化-----------------*/
void init_lcd (void)
{
rst=1;
psb=0;
wr_lcd (comm,0x30); /*30---基本指令動作*/
wr_lcd (comm,0x01); /*清屏,地址指針指向00H*/
delay (100);
wr_lcd (comm,0x06); /*游標的移動方向*/
wr_lcd (comm,0x0c); /*開顯示,關游標*/
}
/*---------------顯示漢字或字元----------------*/
void chn_disp (uchar code *chn)
{
uchar i,j;
wr_lcd (comm,0x30);
wr_lcd (comm,0x80);
for (j=0;j<4;j++)
{
for (i=0;i<16;i++)
wr_lcd (dat,chn[j*16+i]);
}
}
/*-----------上半屏顯示漢字或字元------------*/
void chn_disp1 (uchar code *chn)
{
uchar i,j;
wr_lcd (comm,0x30);
wr_lcd (comm,0x80);
j=0;
for (i=0;i<16;i++)
wr_lcd (dat,chn[j*16+i]);
wr_lcd (comm,0x90);
j=1;
for (i=0;i<16;i++)
wr_lcd (dat,chn[j*16+i]);
}
/*----------------顯示圖形-----------------*/
void img_disp (uchar code *img)
{
uchar i,j;
for(j=0;j<32;j++)
{
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34);
wr_lcd (comm,y+j);
wr_lcd (comm,x1+i);
wr_lcd (comm,0x30);
wr_lcd (dat,img[j*16+i*2]);
wr_lcd (dat,img[j*16+i*2+1]);
}
}
for(j=32;j<64;j++)
{
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34);
wr_lcd (comm,y+j-32);
wr_lcd (comm,x2+i);
wr_lcd (comm,0x30);
wr_lcd (dat,img[j*16+i*2]);
wr_lcd (dat,img[j*16+i*2+1]);
}
}
wr_lcd (comm,0x36);
}
/*-------------下半屏顯示圖形--------------*/
void img_disp1 (uchar code *img)
{
uchar i,j;
for(j=0;j<32;j++)
{
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34);
wr_lcd (comm,y+j);
wr_lcd (comm,x2+i);
wr_lcd (comm,0x30);
wr_lcd (dat,img[j*16+i*2]);
wr_lcd (dat,img[j*16+i*2+1]);
}
}
wr_lcd (comm,0x36);
}
/*--------------顯示點陣----------------*/
void lat_disp (uchar data1,uchar data2)
{
uchar i,j,k,x;
x=x1;
for(k=0;k<2;k++)
{
for(j=0;j<16;j++)
{
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34);
wr_lcd (comm,y+j*2);
wr_lcd (comm,x+i);
wr_lcd (comm,0x30);
wr_lcd (dat,data1);
wr_lcd (dat,data1);
}
for(i=0;i<8;i++)
{
wr_lcd (comm,0x34);
wr_lcd (comm,y+j*2+1);
wr_lcd (comm,x+i);
wr_lcd (comm,0x30);
wr_lcd (dat,data2);
wr_lcd (dat,data2);
}
}
x=x2;
}
wr_lcd (comm,0x36);
}
/*-----------------------------------------------*/
//當data1=0xff,data2=0xff時,在x0,y0處反白顯示16xl*yl.
void con_disp (uchar data1,uchar data2,uchar x0,uchar y0,uchar xl,uchar yl)
{
uchar i,j;
for(j=0;j<yl;j++)
{
for(i=0;i<xl;i++)
{
wr_lcd (comm,0x34);
wr_lcd (comm,y0+j);
wr_lcd (comm,x0+i);
wr_lcd (comm,0x30);
wr_lcd (dat,data1);
wr_lcd (dat,data2);
}
}
wr_lcd (comm,0x36);
}
/*--------------清DDRAM------------------*/
void clrram (void)
{
wr_lcd (comm,0x30);
wr_lcd (comm,0x01);
delay (180);
}
/*---------------------------------------*/
void wr_lcd (uchar dat_comm,uchar content)
{
uchar a,i,j;
delay (50);
a=content;
cs=1;
sclk=0;
std=1;
for(i=0;i<5;i++)
{
sclk=1;
sclk=0;
}
std=0;
sclk=1;
sclk=0;
if(dat_comm)
std=1; //data
else
std=0; //command
sclk=1;
sclk=0;
std=0;
sclk=1;
sclk=0;
for(j=0;j<2;j++)
{
for(i=0;i<4;i++)
{
a=a<<1;
std=CY;
sclk=1;
sclk=0;
}
std=0;
for(i=0;i<4;i++)
{
sclk=1;
sclk=0;
}
}
}
/*-----------------------------------*/
void delay (uint us) //delay time
{
while(us--);
}
void delay1 (uint ms)
{
uint i,j;
for(i=0;i<ms;i++)
for(j=0;j<15;j++)
delay(1);
}
/*------------------主程序--------------------*/
void main ()
{
SP=0x5f;
init_lcd ();
while (1)
{
lat_disp (0x00,0x00);
chn_disp (tab1);
con_disp (0xff,0xff,0x8c,0x80,2,16);
delay1 (8000);
clrram();
lat_disp (0xcc,0xcc);
delay1 (8000);
lat_disp (0x00,0x00);
chn_disp1 (tab31);
img_disp1 (tab32);
delay1 (8000);
clrram();
lat_disp (0xff,0x00);
delay1 (8000);
img_disp (tab5);
delay1 (8000);
}
}

閱讀全文

與單片機顯示圖形程序相關的資料

熱點內容
怎麼做解壓神器泡泡版 瀏覽:962
自己動手做一個c編譯器 瀏覽:925
手機如何鏈接谷歌伺服器地址 瀏覽:135
廢掉一個程序員的武功 瀏覽:247
java樹形演算法 瀏覽:639
通達信加鎖指標源碼怎麼看 瀏覽:752
將同名文件移動到部分同名文件夾 瀏覽:401
擺盪指標加壓力線源碼 瀏覽:913
新一代單片機特徵 瀏覽:768
王者的伺服器什麼時候才修好 瀏覽:279
cad歷史命令 瀏覽:39
php博客源代碼 瀏覽:24
cng壓縮機功率 瀏覽:459
pdf批量列印怎麼設置 瀏覽:78
javamap底層 瀏覽:267
賣華為雲伺服器 瀏覽:111
中穎單片機燒錄器 瀏覽:848
pdf轉換成圖片免費軟體 瀏覽:469
編程語言怎麼做出來的 瀏覽:619
文件夾英文名排序 瀏覽:56