Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning JavaScript Robotics

You're reading from  Learning JavaScript Robotics

Product type Book
Published in Nov 2015
Publisher
ISBN-13 9781785883347
Pages 160 pages
Edition 1st Edition
Languages
Concepts
Author (1):
Kassandra Perch Kassandra Perch
Profile icon Kassandra Perch

Table of Contents (16) Chapters

Learning JavaScript Robotics
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Getting Started with JS Robotics Working with Johnny-Five Using Digital and PWM Output Pins Using Specialized Output Devices Using Input Devices and Sensors Moving Your Bot Advanced Movement with the Animation Library Advanced Components – SPI, I2C, and Other Devices Connecting NodeBots to the World, and Where to Go Next Index

Multiple pins with several LEDs


For the next project, we're going to look at the Led object API and test several different methods. This is one of the benefits of Johnny-Five—abstraction. If you can understand the concept of an LED, you can use the Johnny-Five LED object without thinking about the underlying pins or timings. Let's go over the methods that we'll use for our project:

  • on() and off(): These turn an LED on and off. Under abstraction, this sets the pin that is wired to the LED to HIGH and LOW, respectively. We'll be using these in the REPL.

  • blink(time): This turns an LED on and off at a given interval. strobe() and blink() are aliases of each other and do the same thing.

  • pulse(time): This will cause an LED to pulse on and off in an eased manner. This requires an LED wired to a PWM pin. The time argument sets the length of each side of the pulse—500 will mean the LED will fade in for 500 ms and fade out for 500 ms, meaning a 1-second pulse.

  • fade(brightness, ms): This will cause...

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}