Reader small image

You're reading from  Raspberry Pi 3 Projects for Java Programmers

Product typeBook
Published inMay 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781786462121
Edition1st Edition
Languages
Right arrow
Authors (3):
John Sirach
John Sirach
author image
John Sirach

John Sirach works as a Product Owner at Greenhouse Innovation. He has more than 10 years of experience with Internet-related disciplines from connectivity to hosting and Internet Of Things. Currently, he is involved in the open source "PiDome Home Automation platform" project as a passionate Java and JavaFX software developer and project maintainer. In the past 10 years, he has gained experience with large-scale web applications committed to online services with the most experience gained in frontend web development and application middleware.
Read more about John Sirach

Pradeeka Seneviratne
Pradeeka Seneviratne
author image
Pradeeka Seneviratne

Pradeeka Seneviratne is a software engineer with over 10 years' experience in computer programming and systems design. He is an expert in the development of Arduino- and Raspberry Pi-based embedded systems. Pradeeka is currently a full-time embedded software engineer who works with embedded systems and highly scalable technologies. Previously, he worked as a software engineer for several IT infrastructure and technology servicing companies. He collaborated with the Outernet project as a volunteer hardware and software tester for Lighthouse- and Raspberry Pi-based DIY Outernet receivers based on Ku band satellite frequencies. He is also the author of five books: Internet of Things with Arduino Blueprints [Packt Publishing] IoT: Building Arduino-Based Projects [Packt Publishing] Building Arduino PLCs [Apress] Raspberry Pi 3 Projects for Java Programmers [Packt Publishing] Beginning BBC micro:bit [Apress]
Read more about Pradeeka Seneviratne

View More author details
Right arrow

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 different text appearing depending on the light intensity surrounding the LDR.

When there is a lot of light, the display could show information as shown in the following screenshot...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Raspberry Pi 3 Projects for Java Programmers
Published in: May 2017Publisher: PacktISBN-13: 9781786462121

Authors (3)

author image
John Sirach

John Sirach works as a Product Owner at Greenhouse Innovation. He has more than 10 years of experience with Internet-related disciplines from connectivity to hosting and Internet Of Things. Currently, he is involved in the open source "PiDome Home Automation platform" project as a passionate Java and JavaFX software developer and project maintainer. In the past 10 years, he has gained experience with large-scale web applications committed to online services with the most experience gained in frontend web development and application middleware.
Read more about John Sirach

author image
Pradeeka Seneviratne

Pradeeka Seneviratne is a software engineer with over 10 years' experience in computer programming and systems design. He is an expert in the development of Arduino- and Raspberry Pi-based embedded systems. Pradeeka is currently a full-time embedded software engineer who works with embedded systems and highly scalable technologies. Previously, he worked as a software engineer for several IT infrastructure and technology servicing companies. He collaborated with the Outernet project as a volunteer hardware and software tester for Lighthouse- and Raspberry Pi-based DIY Outernet receivers based on Ku band satellite frequencies. He is also the author of five books: Internet of Things with Arduino Blueprints [Packt Publishing] IoT: Building Arduino-Based Projects [Packt Publishing] Building Arduino PLCs [Apress] Raspberry Pi 3 Projects for Java Programmers [Packt Publishing] Beginning BBC micro:bit [Apress]
Read more about Pradeeka Seneviratne