GY-30感光模块.doc_第1页
GY-30感光模块.doc_第2页
GY-30感光模块.doc_第3页
GY-30感光模块.doc_第4页
GY-30感光模块.doc_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

:GY-30ROHMBH1750FVI 3-5v0-65535 lx16bitAD1NXP IIC5vioSTC 51 CAVR M16 C1967/1.candela1.candela1013251/60Pt2042K17691 60 58.810.8850.9192.candelacdLcdI=F/sr,FI=F/4 /cd/m²1.5*10 510*10³2.5*10³120803.lumenlm5.305*10³cm²1lm11140W21004.luxlx111lux0.0010.020.020.355050500100100010*650601400 1967 /1. candela1. candela1013251/60Pt2042K17691 60 58.810.8850.9192. candelacdLcdI=F/sr,FI=F/4 /cd/m²1.5*10 510*10³2.5*10³120803. lumenlm5.305*10³cm²1lm11140W21004. luxlx111lux0.0010.020.020.355050500100100010*650601400 C/C+/*/ BH1750FVI IIC/ STC89C52/ 11.0592M,12M/ ,4800/ Keil uVision2/ 24c04/ 20121127/ Mr Lee/*#include #include /Keil library#include /Keil library#include #define uchar unsigned char#define uint unsigned int#define SlaveAddress 0x46 /IIC,ALT ADDRESS/ALT ADDRESS0x460xB8sbit SCL=P10; /IICsbit SDA=P11; /IICtypedef unsigned char BYTE;typedef unsigned short WORD;BYTE BUF8; /uchar ge,shi,bai,qian,wan; /int dis_data; /void delay_nms(unsigned int k);void Init_BH1750(void);void conversion(uint temp_data);void Single_Write_BH1750(uchar REG_Address); /uchar Single_Read_BH1750(uchar REG_Address); /void Multiple_Read_BH1750(); /-void Delay5us();void Delay5ms();void BH1750_Start(); /void BH1750_Stop(); /void BH1750_SendACK(bit ack); /ACKbit BH1750_RecvACK(); /ackvoid BH1750_SendByte(BYTE dat); /IICBYTE BH1750_RecvByte(); /IIC/-/*void conversion(uint temp_data) / wan=temp_data/10000+0x30 ;temp_data=temp_data%10000; /qian=temp_data/1000+0x30 ;temp_data=temp_data%1000; /bai=temp_data/100+0x30 ;temp_data=temp_data%100; /shi=temp_data/10+0x30 ;temp_data=temp_data%10; /ge=temp_data+0x30;/*void delay_nms(unsigned int k)unsigned int i,j;for(i=0;ik;i+)for(j=0;j121;j+);/*5(STC90C52RC12M),1TMCU,*/void Delay5ms()WORD n = 560;while (n-);/*5(STC90C52RC12M),1TMCU,*/void Delay5us()_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();_nop_();/*/void BH1750_Start()SDA = 1; /SCL = 1; /Delay5us(); /SDA = 0; /Delay5us(); /SCL = 0; /*/void BH1750_Stop()SDA = 0; /SCL = 1; /Delay5us(); /SDA = 1; /Delay5us(); /*:ack (0:ACK 1:NAK)*/void BH1750_SendACK(bit ack)SDA = ack; /SCL = 1; /Delay5us(); /SCL = 0; /Delay5us(); /*/bit BH1750_RecvACK()SCL = 1; /Delay5us(); /CY = SDA; /SCL = 0; /Delay5us(); /return CY;/*IIC*/void BH1750_SendByte(BYTE dat)BYTE i;for (i=0; i8; i+) /8dat = 1; /SDA = CY; /SCL = 1; /Delay5us(); /SCL = 0; /Delay5us(); /BH1750_RecvACK();/*IIC*/BYTE BH1750_RecvByte()BYTE i;BYTE dat = 0;SDA = 1; /,for (i=0; i8; i+) /8dat = 1;SCL = 1; /Delay5us(); /dat |= SDA; /SCL = 0; /Delay5us(); /return dat;/*void Single_Write_BH1750(uchar REG_Address)BH1750_Start(); /BH1750_SendByte(SlaveAddress); /+BH1750_SendByte(REG_Address); / BH1750_SendByte(REG_data); /BH1750_Stop(); /*/*uchar Single_Read_BH1750(uchar REG_Address) uchar REG_data;BH1750_Start(); /BH1750_SendByte(SlaveAddress); /+BH1750_SendByte(REG_Address); /0BH1750_Start(); /BH1750_SendByte(SlaveAddress+1); /+REG_data=BH1750_RecvByte(); /BH1750_SendACK(1);BH1750_Stop(); /return REG_data;*/*/BH1750/*void Multiple_read_BH1750(void) uchar i;BH1750_Start(); /BH1750_SendByte(SlaveAddress+1); /+for (i=0; i3; i+) /2BUFBUFi = BH1750_RecvByte(); /BUF00x32if (i = 3)BH1750_SendACK(1); /NOACKelseBH1750_SendACK(0); /ACKBH1750_Stop(); /Delay5ms();/BH1750pdf*void Init_BH1750()Single_Write_BH1750(0x01);void uart_init()TMOD=0x20; /TMOD0TH1=0xf3; /12MHZ BPS4800N81,0xf3=243TL1=0xf3;PCON=0x80; /,8TR1=1; /SCON=0x40; / void uart_putchar(unsigned char dat)SBUF=dat; /sbufwhile(TI!=1);/ TI10TI=0; /TI0void uart_printf(unsigned char *buff)while(*buff)uart_putchar(*buff+);/*/*/*void main()float temp;unsigned char str5;/delay_nms(100); /100msuart_init();Init_BH1750(); /BH1750while(1) /Single_Write_BH1750(0x01); / power onSingle_Write_BH1750(0x10); / H- resolution modedelay_nms(180); /180msMultiple_Re

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论