<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 設(shè)計應(yīng)用 > 一個單片機比例因子控制的例子

          一個單片機比例因子控制的例子

          作者: 時間:2016-11-29 來源:網(wǎng)絡(luò) 收藏
          //模塊S2-----單片機P1.1
          //模塊S3-----單片機P1.0//模塊OUT----單片機P3.5(計數(shù)器1輸入)//模塊VCC----單片機VCC//模塊GND----單片機GND//K4按一次進入比例因子調(diào)節(jié)模式,再按退出;探測時按K8重置//K1+,K5-控制R比例因子 K2+,K6-控制B比例因子 K3+,K7-控制G比例因子#include	#include       //Keil library  #include      //Keil library	#include#define uchar unsigned char#define uint  unsigned int	#define DataPort P0	  //LCD1602 數(shù)據(jù)端口sbit    LCM_RS=P2^6;   //LCD1602 控制端口	sbit    LCM_RW=P2^5;   //LCD1602 控制端口	sbit    LCM_EN=P2^7;   //LCD1602 控制端口/**引腳定義**/  sbit s2=P1^1;        //TCS3200 S2 sbit s3=P1^0;        //TCS3200 S3//TCS3200 S0 模塊內(nèi)部默認(rèn)上拉//TCS3200 S1 模塊內(nèi)部默認(rèn)上拉//TCS3200 OE 模塊內(nèi)部接地sbit test_pin=P2^2;  //用示波器看這個引腳,可知道定時器中斷頻率sbit K8=P1^7;sbit K1=P2^1;sbit K2=P2^0;sbit K3=P1^2;	sbit K4=P1^3;sbit K5=P1^4;sbit K6=P1^5;sbit K7=P1^6;//變量、常量定義uchar ge,shi,bai ;uchar rp=3,gp=3,bp=6; //定義比例因子,具體環(huán)境可以修改uchar count;          //顏色標(biāo)志位(0:紅 1:綠 2:藍(lán))uint    ryz,gyz,byz;//分別定義紅色因子 綠色因子 藍(lán)色因子//顯示數(shù)組uchar disp_R[3];  //紅uchar disp_G[3];  //綠uchar disp_B[3];  //藍(lán)uchar disp_rp[3];uchar disp_bp[3];uchar disp_gp[3];//********定義函數(shù)*****************************void    delay(unsigned int k);void    InitLcd();void    WriteDataLCM(uchar dataW);void    WriteCommandLCM(uchar CMD,uchar Attribc);void    DisplayOneChar(uchar X,uchar Y,uchar DData);void    baipingheng();//白平衡子程序void    DisplayRGB();//顯示比例因子//*********LCD1602初始化**********************void InitLcd()	{	WriteCommandLCM(0x38,1);	WriteCommandLCM(0x08,1);	WriteCommandLCM(0x01,1);WriteCommandLCM(0x06,1);	WriteCommandLCM(0x0c,1);}//**********檢測忙信號************************void WaitForEnable(void)	{	DataPort=0xff;	LCM_RS=0;LCM_RW=1;_nop_();LCM_EN=1;_nop_();_nop_();while(DataPort&0x80);	LCM_EN=0;	}//**********寫命令至LCD***********************void WriteCommandLCM(uchar CMD,uchar Attribc){	if(Attribc)WaitForEnable();	LCM_RS=0;LCM_RW=0;_nop_();DataPort=CMD;_nop_();	LCM_EN=1;_nop_();_nop_();LCM_EN=0;}	//**********寫數(shù)據(jù)至LCD************************void WriteDataLCM(uchar dataW){	WaitForEnable();	LCM_RS=1;LCM_RW=0;_nop_();DataPort=dataW;_nop_();	LCM_EN=1;_nop_();_nop_();LCM_EN=0;}//*********寫一個字符數(shù)據(jù)到指定的目標(biāo)***********void DisplayOneChar(uchar X,uchar Y,uchar DData){	Y&=1;	X&=15;	if(Y)X|=0x40;	X|=0x80;	WriteCommandLCM(X,0);	WriteDataLCM(DData);	}//**********延時函數(shù)***************void delay(unsigned int k)	{	unsigned int i,j;	for(i=0;i
          				
                      
                          
          			
          							
          上一頁 1 2 下一頁

          關(guān)鍵詞: 單片機比例因

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();