Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Android Things Projects

You're reading from  Android Things Projects

Product type Book
Published in Jun 2017
Publisher Packt
ISBN-13 9781787289246
Pages 232 pages
Edition 1st Edition
Languages
Author (1):
Francesco Azzola Francesco Azzola
Profile icon Francesco Azzola

Table of Contents (15) Chapters

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
Getting Started with Android Things Creating an Alarm System Using Android Things How to Make an Environmental Monitoring System Integrate Android Things with IoT Cloud Platforms Create a Smart System to Control Ambient Light Remote Weather Station Build a Spying Eye Android with Android Things

How to control GPIO pins


Now that we know how to read the environment parameters, we can implement the application logic to control other peripherals according to the values acquired. As described in the previous sections, the Android Things monitoring app uses the temperature and pressure to controls two devices:

  • An RGB LED that shows the current pressure state
  • A RED LED that shows if the temperature is lower than a threshold

To make the app work, we have to fix the pressure threshold values. To simplify the development process we can suppose that there are two thresholds:

  • Threshold one, that we will call LEVEL_1, is 1022.9 mb
  • Threshold two, that we will call LEVEL_2, is 1009.14 mb

The app logic that we will implement works in this way:

  • If the current pressure is over the LEVEL_1 then the RGB LED will have the green and red color turned on (yellow)
  • If the current pressure is between LEVEL_1 and LEVEL_2 the RGB LED will have only the green color turned on
  • If the current pressure is below LEVEL_2...
lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}