Close or Esc Key

Arduino Projects   |   Raspberry Pi   |   Electronic Circuits   |   AVR   |   PIC   |   8051   |   Electronic Projects

Interfacing BH1750 sennsor with Atmega8

2 posts / 0 new
Last post
mubarra shaikh
mubarra shaikh's picture
Last seen: 2 weeks 3 days ago
Joined: 06/07/2014 - 00:59
Interfacing BH1750 sennsor with Atmega8


I am trying to interface Atmega8 with BH1750 digital light sensor and displayin intensity on LCD.

I am getting decimel values on LCD.But I want to display fraction values.  I tried a lot but failed..

can anybody please help. following is main program ...



#include <avr/io.h>
#include <stdio.h>
#include <stdlib.h>
#include <util/delay.h>
#include <avr/interrupt.h>
#include "C:\Users\mubar\Desktop\atmega32\light intensity\src\bh1750/bh1750.h"
#include <avr/pgmspace.h>
#include "C:\Users\mubar\Desktop\atmega32\LCDDemo1\LCDDemo1\lib\lcd/lcd_hd44780_avr.h"
int main(void)
LCDWriteFString(PSTR("LCD Test !"));
char printbuff[200];
//infinite loop
float lux = bh1750_getlux();
Ashutosh Bhatt
Ashutosh Bhatt's picture
Last seen: 1 week 6 hours ago
Joined: 21/12/2010 - 15:59
for displaying fraction

for displaying fraction values on LCD you have to do some juggling with digits.

first get the final answer in float (may be with 2 digit after decimal point)

now multiply this answer with 100 - so you will get final value without decimal point

now convert all digits of this value into ASCII characters and print these values

one by one on LCD with one decimal point in between