Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Internet of things with Intel Galileo

You're reading from   Internet of things with Intel Galileo Employ the Intel Galileo board to design a world of smarter technology for your home

Arrow left icon
Product type Paperback
Published in Jul 2015
Publisher
ISBN-13 9781782174585
Length 212 pages
Edition 1st Edition
Tools
Arrow right icon
Toc

Table of Contents (12) Chapters Close

Preface 1. Introducing Galileo 2. Rediscovering the Arduino IDE FREE CHAPTER 3. Monitoring the Board Temperature 4. Creating a Motion Sensing Light 5. Intel IoT Developer Kit Tools 6. Building an Irrigation System 7. Creating Christmas Light Effects 8. The Intel XDK IoT Edition 9. Developing an IoT Quiz 10. Integrating with Muzzley Index

Launching random LED animations


The one thing that we'll want to do while the videos are playing is to play a random LED animation. To do so, we'll create a new file and develop some methods to help us handle those animations.

The idea is to have a method to stop and set the strip off and the other to select a couple of colors and play an animation, switching between those colors randomly.

To control the LED strip, we will use the lib UPM jsupm_lpd8806 and to loop between the strip LEDs, we will need to use the async module, which will provide us with asynchronous loops. Together with the setTimeout method, this will help us keep the process non-blocking.

Firstly, let's start by installing the async module by typing npm install async inside the project folder (chapter7). When it finishes installing, create a new file by typing vi animations.js and paste the following code:

var LPD8806 = require('jsupm_lpd8806').LPD8806;
var async = require('async');

var stripLength = 30;
var ledstrip = new...
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 $19.99/month. Cancel anytime
Banner background image