Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletter Hub
Free Learning
Arrow right icon
timer SALE ENDS IN
0 Days
:
00 Hours
:
00 Minutes
:
00 Seconds
Arrow up icon
GO TO TOP
Android Things Projects

You're reading from   Android Things Projects Efficiently build IoT projects with Android Things

Arrow left icon
Product type Paperback
Published in Jun 2017
Publisher Packt
ISBN-13 9781787289246
Length 232 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Francesco Azzola Francesco Azzola
Author Profile Icon Francesco Azzola
Francesco Azzola
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Title Page
Credits
About the Author
About the Reviewers
www.PacktPub.com
Customer Feedback
Preface
1. Getting Started with Android Things FREE CHAPTER 2. Creating an Alarm System Using Android Things 3. How to Make an Environmental Monitoring System 4. Integrate Android Things with IoT Cloud Platforms 5. Create a Smart System to Control Ambient Light 6. Remote Weather Station 7. Build a Spying Eye 8. 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
Visually different images