⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 text1.c

📁 单片机快速入门原程序
💻 C
字号:
#include <reg51.h>
#include<stdio.h>
void Uart_Init();
main()
{	int nVar1;
	Uart_Init();
	while(1)
	{	printf("Input a character: \n");
		nVar1=getchar();		//输入字符
printf("\n");
		switch(nVar1)
			{case('0'): printf("case 0 switched\n");
					break;	//跳出
			 case('1'): printf("case 1 switched\n");;
					break;
			 case('2'): printf("case 2 switched\n");;
					break;
			 default: printf(" default case \n");
					break;
			}
	}
}
void Uart_Init()
{      SCON = 0x52;    /* SCON */        /* setup serial port control */
	  TMOD = 0x20;    /* TMOD */        /* hardware (2400 BAUD @12MHZ) */
	  TCON = 0x69;    /* TCON */
	  TH1 =  0xf3;    /* TH1 */
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -