tft每日頭條

 > 科技

 > AT89C51驅動OLED液晶屏的應用代碼

AT89C51驅動OLED液晶屏的應用代碼

科技 更新时间:2024-11-23 03:14:13

AT89C51驅動OLED液晶屏的應用代碼?#include <reg51.h>#include <stdio.h>,我來為大家講解一下關于AT89C51驅動OLED液晶屏的應用代碼?跟着小編一起來看一看吧!

AT89C51驅動OLED液晶屏的應用代碼(AT89C51驅動OLED液晶屏的應用代碼)1

AT89C51驅動OLED液晶屏的應用代碼

#include <reg51.h>

#include <stdio.h>

sbit OLED_SCL = P1^0;

sbit OLED_SDA = P1^1;

void OLED_IIC_Start()

{

OLED_SDA = 1;

OLED_SCL = 1;

OLED_SDA = 0;

OLED_SCL = 0;

}

void OLED_IIC_Stop()

{

OLED_SDA = 0;

OLED_SCL = 1;

OLED_SDA = 1;

OLED_SCL = 0;

}

void OLED_IIC_Write_Byte(unsigned char IIC_Byte)

{

unsigned char i;

for (i=0;i<8;i )

{

OLED_SCL = 0;

if (IIC_Byte & 0x80) OLED_SDA = 1;

else OLED_SDA = 0;

OLED_SCL = 1;

IIC_Byte <<= 1;

}

OLED_SCL = 0;

OLED_SDA = 1;

OLED_SCL = 1;

OLED_SDA = 1;

}

void OLED_Init()

{

OLED_IIC_Start();

OLED_IIC_Write_Byte(0x78);

OLED_IIC_Write_Byte(0x00);

OLED_IIC_Write_Byte(0xD5);

OLED_IIC_Write_Byte(0x80);

OLED_IIC_Write_Byte(0xA8);

OLED_IIC_Write_Byte(0x3F);

OLED_IIC_Write_Byte(0xD3);

OLED_IIC_Write_Byte(0x00);

OLED_IIC_Write_Byte(0x40);

OLED_IIC_Write_Byte(0x8D);

OLED_IIC_Write_Byte(0x14);

OLED_IIC_Write_Byte(0x20);

OLED_IIC_Write_Byte(0x00);

OLED_IIC_Write_Byte(0xA1);

OLED_IIC_Write_Byte(0xC8);

OLED_IIC_Write_Byte(0xDA);

OLED_IIC_Write_Byte(0x12);

OLED_IIC_Write_Byte(0x81);

OLED_IIC_Write_Byte(0xCF);

OLED_IIC_Write_Byte(0xD9);

OLED_IIC_Write_Byte(0xF1);

OLED_IIC_Write_Byte(0xDB);

OLED_IIC_Write_Byte(0x40);

OLED_IIC_Write_Byte(0xA4);

OLED_IIC_Write_Byte(0xA6);

OLED_IIC_Write_Byte(0xAF);

OLED_IIC_Stop();

}

void OLED_Set_Pos(unsigned char x, unsigned char y)

{

OLED_IIC_Start();

OLED_IIC_Write_Byte(0x78);

OLED_IIC_Write_Byte(0x00);

OLED_IIC_Write_Byte(0xB0 y);

OLED_IIC_Write_Byte(((x&0xF0)>>4)|0x10);

OLED_IIC_Write_Byte((x&0x0F)|0x01);

OLED_IIC_Stop();

}

void OLED_Show_Str(unsigned char x,unsigned char y,char *chr)

{

unsigned char c=0,l=0;

while (chr[c]!='\0')

{

l=chr[c];

OLED_Set_Pos(x,y);

,

更多精彩资讯请关注tft每日頭條,我们将持续为您更新最新资讯!

查看全部

相关科技资讯推荐

热门科技资讯推荐

网友关注

Copyright 2023-2024 - www.tftnews.com All Rights Reserved