Reading and displaying the values from the LDR

Doing this needs some experimentation on the values we want to have, especially because everyone's definition of It is dark is different. Remember, the longer it takes for the pin to detect the high state, the darker it is.

Close all the tabs except the Main class, where we will be uncommenting the next example to run. Scroll to the main function where we will be commenting the runLcdExample(); and uncomment the runLdrExample(); method. This next method runs the example of how to measure light intensity. When the LDR is connected like in the previous directions, you are able to run the application again by pressing the Run button in the button bar. Take a look at the LCD display where we see ...

Get Raspberry Pi 3 Projects for Java Programmers now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.