Serial Print Light Sensor Readings
Step 1 - Build the Project
The light sensor is simple, reliable, and really useful. Once you understand how to use it, you'll find hundreds of uses for it.
Step 2 - Upload the Code
Step 3 - Read the Walkthrough
First, make either pin of the light sensor an INPUT_PULLUP in the pinMode.The light sensor is reversible, you can plug it in either way with no difference in how it works. Using the INPUT_PULLUP mode means that you can plug the sensor directly into a Carrier Board. The readings closer to 1023 will actually be for darker environments, so you can think of this sensor as a darkness sensor if that helps.
Start the serial communication with Serial.begin(9600). The 9600 is the communication speed- use 9600 unless you have a reason to use anything else.
The loop will print the label "Light:" and then the reading from the port where your light sensor is plugged in. After you have uploaded your code, press the magnifying glass icon in the upper right-hand side of the Arduino software window with Maker Board still connected to the USB port.
A new window will pop up and values should start immediately streaming in. Cover the light sensor with your hand to see how the values change. Although the sensor can read from 0-1023, it is very difficult to get the readings to the very edges.
In the bottom left-hand side of the window, there is a check box for 'autoscroll'. You can un-check it so that the values don't flow by too quickly for you to see.