售 价:¥
温馨提示:数字商品不支持退换货,不提供源文件,不支持导出打印
为你推荐
Learning JavaScript Robotics
Table of Contents
Learning JavaScript Robotics
Credits
About the Author
About the Reviewers
www.PacktPub.com
Support files, eBooks, discount offers, and more
Why subscribe?
Free access for Packt account holders
Preface
What this book covers
What you need for this book
Who this book is for
Conventions
Reader feedback
Customer support
Downloading the example code
Downloading the color images of this book
Errata
Piracy
Questions
1. Getting Started with JS Robotics
Understanding JS Robotics, NodeBots, and Johnny-Five
What a NodeBot is, and other basic vocabulary
Johnny-Five and the NodeBot revolution
What we'll be using in this book
Setting up your development environment
Installing Node.JS
Setting up your project and installing Johnny-Five
Connecting your Microcontroller and installing Firmata
Hello, World! – Blinking an onboard LED
Writing the Johnny-Five script
Running the script
Summary
2. Working with Johnny-Five
What you'll need for this chapter
How a Johnny-Five program works
Objects, functions, and events
Going over our blink-LED script
Understanding events in Johnny-Five
Why events?
Wiring up an external LED
Setting up the hardware
Using the Read-Eval-Print-Loop (REPL)
Making components available to the REPL
Using the REPL
Summary
3. Using Digital and PWM Output Pins
What you'll need for this chapter
How GPIO pins work
Digital output pins
PWM output pins
How to tell the difference between Digital and PWM pins
Multiple pins with several LEDs
Setting up the hardware for the project
Writing the script for the project
Exploring more about LED objects in Johnny-Five
Using PWM pins with the Piezo element
Setting up the hardware
Writing the script
What's going on with the pin?
Exploring the Piezo API
Summary
4. Using Specialized Output Devices
What you'll need for this chapter
Outputs that require multiple pins
Inter-Integrated Circuits (I2C)
Checking compatibility with Johnny-Five
Obtaining documentation, wiring diagrams, and so on
Project – character LCD display
Wiring up – I2C LCDs
The code
The I2C version
The non-I2C version
Running the code
Summary
5. Using Input Devices and Sensors
What you'll need for this chapter
How analog input pins work
Johnny-Five sensor events
Using basic inputs – buttons and potentiometers
Wiring up our button and LED
Coding button-led.js
Wiring the potentiometer and the LED
Coding our dimmer switch
Using sensors – Light and Temperature
Wiring up our photocell
Coding our photocell example
barcli
Coding everything together
Wiring up the temperature sensor
Coding our temperature example
Summary
6. Moving Your Bot
What you'll need for this chapter
The different kinds of servos and motors
Defining motors and servos
Things to keep in mind
Types of motors
Types of servos
Do I use a servo or a motor?
Servo and motor controllers
Motor and servo shields
Special concerns when using motors and servos
Power concerns
Tethering and cables
Wiring up servos and motors
Wiring up servos
Wiring up motors
Creating a project with a motor and using the REPL
Exploring the motor API
Creating a project with a servo and a sensor
Exploring the servo API with the REPL
Summary
7. Advanced Movement with the Animation Library
What you'll need for this chapter
What is the Animation API?
Why do we need an Animation API?
Why animation?
Looking at the Animation API
Learning the terminology
The difference between .to() and the Animation API
Using the ServoArray object
Project – wiring up three servos and creating an array
Writing Servo Animations
Writing keyframes
The keyframe object
Keyframe shorthand
Examples of writing keyframes
Writing segments
Segment options
Multiple servos in one segment
Examples of writing segments
The Animation object
Project – animating our servo array
Animation events
Building a servo array with an informative LCD readout
Summary
8. Advanced Components – SPI, I2C, and Other Devices
What you'll need for this chapter
Why do we need the I2C and SPI protocols?
Exploring SPI (Serial Peripheral Interface) devices
How SPI works
How Johnny-Five does SPI
Benefits and drawbacks of SPI
Building with an SPI device – an LED matrix
The build
The API
Formatting data for the LED matrix
The Drawing functions
The Code
Exploring I2C devices
How I2C works
Pins used by I2C
How I2C devices send and receive data
Benefits and drawbacks of I2C
Benefits
Drawbacks
Building with an I2C device – Accelerometer
Wiring up our accelerometer
Coding up our example
External Devices
Why External Devices?
node-serialport
node-hid
Building a USB gamepad
The hardware
The node-gamepad API
The code
Summary
9. Connecting NodeBots to the World, and Where to Go Next
What you'll need for this chapter
Connecting NodeBots to the Web
It's just a Node Server!
Using Twilio
Building the WeatherBot
Using the TextBot
Johnny-Five and the wide world of microcontrollers
Moving our WeatherBot to the Particle Photon
Tethering and Johnny-Five
Other JS libraries and platforms
Espruino
Tessel
Cylon.js
JerryScript
Tiny Linux computers
Vendor libraries
Where to go from here
Index
买过这本书的人还买过
读了这本书的人还在读
同类图书排行榜