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

Automatic switch based on environment lighting

In this section, we will be combining the built hardware components to automate the switching of the relay based on the environment lighting, including printing states to the LCD. Let's close all the code tabs in the editor and leave only the Main class open. If not already done, comment the relayExample(); method and uncomment the lightDependentSwitching() method. This last method will instantiate the LdrHandler class and pass on a RelaySwitch object. If you already have been playing with the darkThreshold member value in the LdrHandler class, you can press the Run application button and the application should start switching automatically and update the LCD statuses. When we play a little bit with the environment lighting by putting our hand over the LDR, the relay should close, and when light is reaching the LDR again, the relay should open.

We now have this...

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