Hello I have a problem with my Arduino Uno and a light sensor.
I have connected a light sensor to my Arduino Uno with I2C and would now like to output the value measured by the light sensor to my serial. Now my question Could you please tell me how I have to rewrite the code so that I get an output or tell me straight away what I am doing wrong.
Thanks for your help
// demo of Starter kit V2.0 - Grove - Light Sensor
// when the value of light sensor ledd than a certain value
// led will on, you can set this certain value via change thresholdvalue
// such as when you cover light sensor with your hand, you'll find led on
const int pinLight = A0;
const int pinLed = 7;
int thresholdvalue=400; //the threshold to turn on or off the LED
void setup()
{
pinMode(pinLed, OUTPUT); //set the LED on Digital 12 as an OUTPUT
}
void loop()
{
int sensorValue = analogRead(pinLight); //the light sensor is attached to analog 0