万本电子书0元读

万本电子书0元读

顶部广告

Learning JavaScript Robotics电子书

售       价:¥

30人正在读 | 0人评论 9.8

作       者:Kassandra Perch

出  版  社:Packt Publishing

出版时间:2015-11-25

字       数:75.8万

所属分类: 进口书 > 外文原版书 > 电脑/网络

温馨提示:此类商品不支持退换货,不支持下载打印

为你推荐

  • 读书简介
  • 目录
  • 累计评论(0条)
  • 读书简介
  • 目录
  • 累计评论(0条)
Design, build, and program your own remarkable robots with JavaScript and open source hardware About This Book Learn how to leverage Johnny-Five's Read, Eval, Print Loop, and Event API to write robot code with JavaScript Unlock a world of exciting possibilities by hooking your JavaScript-programmed robots up to the internet and using external data and APIs Move your project code from the Arduino Uno to a multitude of other robotics platforms Who This Book Is For If you've worked with Arduino before or are new to electronics and would like to try writing sketches in JavaScript, then this book is for you! Basic knowledge of JavaScript and Node.js will help you get the most out of this book. What You Will Learn Familiarise yourself with Johnny-Five Read, Eval, and Print Loop (REPL) to modify and debug robotics code in real time Build robots with basic output devices to create projects that light up, make noise, and more Create projects with complex output devices, and employ the Johnny-Five API to simplify the use of components that require complex interfaces, such as I2C Make use of sensors and input devices to allow your robotics projects to survey the world around them and accept input from users Use the Sensor and Motor objects to make it much easier to move your robotics projects Learn about the Animation API that will allow you to program complex movements using timing and key frames Bring in other devices to your Johnny-Five projects, such as USB devices and remotes Connect your Johnny-Five projects to external APIs and create your own Internet of Things! In Detail There has been a rapid rise in the use of JavaScript in recent times in a variety of applications, and JavaScript robotics has seen a rise in popularity too. Johnny-Five is a framework that gives NodeBots a consistent API and platform across several hardware systems. This book walks you through basic robotics projects including the physical hardware builds and the JavaScript code for them. You'll delve into the concepts of Johnny-Five and JS robotics. You'll learn about various components such as Digital GPIO pins, PWM output pins, Sensors, servos, and motors to be used with Johnny-Five along with some advanced components such as I2C, and SPI. You will learn to connect your Johnny-Five robots to internet services and other NodeBots to form networks. By the end of this book, you will have explored the benefits of the Johnny-Five framework and the many devices it unlocks. Style and approach This step-by-step guide to the Johnny-Five ecosystem is explained in a conversational style, packed with examples and tips. Each chapter also explores the Johnny-Five documentation to enable you to start exploring the API on your own.
目录展开

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

累计评论(0条) 0个书友正在讨论这本书 发表评论

发表评论

发表评论,分享你的想法吧!

买过这本书的人还买过

读了这本书的人还在读

回顶部