1.流水灯C程序
#include
////////////////////////////////////////////////////////
void delay(unsigned int cnt) //简单的延时
{
}
///////////////////////////////////////////////////////
main()
{
}
2.数码管动态扫描C程序
#include
unsigned char const dofly[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f};// 显示段码值01234567
unsigned char code seg[]={0,1,2,3,4,5,6,7};//分别对应相应的数码管点亮
////////////////////////////////////////////////////////
void delay(unsigned int cnt)
{
}
///////////////////////////////////////////////////////
main()
{
}
3.LED
/\/\
\ /
#include
unsigned char const dofly[]={0x00,0x6C,0x92,0x82,0x44,0x28,0x10,0x00};// 心的形状
unsigned char code seg[]={0x7f,0xbf,0xdf,0xef,0xf7,0xfb,0xfd,0xfe};//分别对应相应的段亮
////////////////////////////////////////////////////////
void delay(unsigned int cnt)
{
}
///////////////////////////////////////////////////////
main()
{
}
4.实时时钟RTC
#include
#include
sbit SCK=P3^6;
sbit SDA=P3^4;
sbit RST = P3^5;
bit ReadRTC_Flag;
unsigned char l_tmpdate[7]={0,0,12,15,5,3,8};//秒分时日月周年08-05-15 12:00:00
unsigned char l_tmpdisplay[8];
code unsigned char write_rtc_address[7]={0x80,0x82,0x84,0x86,0x88,0x8a,0x8c}; //秒分时日月周年 最低位读写位
code unsigned char read_rtc_address[7]={0x81,0x83,0x85,0x87,0x89,0x8b,0x8d};
code unsigned char table[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x40};
code unsigned char table1[]={0,1,2,3,4,5,6,7};
void Write_Ds1302_byte(unsigned char temp);
void Write_Ds1302( unsigned char address,unsigned char dat );
unsigned char Read_Ds1302 ( unsigned char address );
void Read_RTC(void);//read RTC
void Set_RTC(void); //set RTC
void InitTIMER0(void);//inital timer0
void main(void)
{
}
void InitTIMER0(void)
{
}
void Write_Ds1302_Byte(unsigned
{
}
void Write_Ds1302( unsigned char address,unsigned char dat )
{
}
unsigned char Read_Ds1302 ( unsigned char address )
{
}
void Read_RTC(void)
{
}
void Set_RTC(void)
{
}
void tim(void) interrupt 1 using 1//中断,用于数码管扫描
{
5.4*4矩阵键盘
//行列扫描程序,可以自己定义端口和扫描方式,这里做简单介绍
#include
#define uchar unsigned char
#define uint
unsigned char const dofly[]={0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,
uchar keyscan(void);
void delay(uint i);
void main()
{
{
}
uchar keyscan(void)//键盘扫描函数,使用行列反转扫描法
{
}
void delay(uint i)//延时函数
{
while(i--);
}
6.红外解码LCD显示
//该程序使用LCD1602显示
#include
#include
#include
////////////////////////////////////////////////
#define TURE 1
#define FALSE 0
////////////////////////////////////////////////
sbit IR=P3^2;//红外接口标志
sbit RS = P2^4;//Pin4
sbit RW = P2^5; //Pin5
sbit E
#define Data
unsigned int hour,minute,second,count;
char code Tab[16]="0123456789ABCDEF";
char data TimeNum[]="
char data Test1[]="
////////////////////////////////////////////
unsigned char
bit irpro_ok,irok;
unsigned char IRcord[4];
unsigned char
void ShowString (unsigned char line,char *ptr);
//////////////////////////////////////////////
void Delay(unsigned char mS);
void Ir_work(void);
void Ircordpro(void);
////////////////////////////////////////////////////////////////
void Delay(unsigned char mS)//delay mS
{
}
//////////////////////////////////////////////////////////////////
/
void Ircordpro(void)//红外码值处理函数
{
}
void DelayUs(unsigned char us)//delay us
{
}
void DelayMs(unsigned char ms)//delay Ms
{
}
void WriteCommand(unsigned char c)
{
}
void WriteData(unsigned char c)
{
}
void ShowChar(unsigned char pos,unsigned char c)
{
}
void ShowString (unsigned char line,char *ptr)
{
}
void InitLcd()
{
}
/////////////////////////////////////////////////////////////////
void main(void)
{
}
7.蜂鸣器
#include
sbit SPK=P1^2;//定义蜂鸣器端口
void delay(unsigned int cnt)//延时
{
}
main()
{
unsigned int i;
}
上一篇:单片机C语言程序举例(三)
下一篇:单片机C语言程序举例(二)
推荐阅读最新更新时间:2024-03-16 14:45