Ambient Light Sensor

Greetings.
I am playing with a BH1750GVI light sensor and using this sketch,

/*
Sample code for the BH1750 Light sensor
Version 0.1
website:www.DFRobot.com

Connection:

VCC-5v
GND-GND
SCL-SCL(analog pin 5)
SDA-SDA(analog pin 4)
ADD-NC
*/

#include <Wire.h> //BH1750 IIC Mode
#include <math.h>
int BH1750address = 0x23; //setting i2c address

byte buff[2];
void setup()
{
Wire.begin();
Serial.begin(57600);//init Serail band rate
}

void loop()
{
int i;
uint16_t val=0;
BH1750_Init(BH1750address);
delay(200);

if(2==BH1750_Read(BH1750address))
{
val=((buff[0]<<8)|buff[1])/1.2;
Serial.print(val,DEC);
Serial.println("");
}
delay(150);
}

int BH1750_Read(int address) //
{
int i=0;
Wire.beginTransmission(address);
Wire.requestFrom(address, 2);
while(Wire.available()) //
{
buff = Wire.read(); // receive one byte

  • i++;*
  • }*
  • Wire.endTransmission(); *
  • return i;*
    }
    void BH1750_Init(int address)
    {
  • Wire.beginTransmission(address);*
  • Wire.write(0x10);//1lx reolution 120ms*
  • Wire.endTransmission();*
    }
    I cannot get a recognisable reading to the serial monitor.
    I have tried altering the serial print and serial.write, but the display shows a continuous line
    of characters, not numbers.
    What should I alter?
    Regards Ant

Ant001:

void setup()

{
  Wire.begin();
  Serial.begin(57600);//init Serail band rate
}




the display shows a continuous line of characters, not numbers.
What should I alter?

Do you have Serial Monitor set to 57600 baud? The speed menu is in the bottom right corner.

I have been altering everything!
It is now sort of working, at 9600 baud it shows a vertical column of numbers
and letters. At 57600 strange characters scroll across the screen.
Once I get solid readings i want to start a stepper motor at a set level of ambient light
Thanks for the help.

Success, Thanks!!!!