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
Explore 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
Hands-On Robotics with JavaScript

You're reading from   Hands-On Robotics with JavaScript Build robotic projects using Johnny-Five and control hardware with JavaScript and Raspberry Pi

Arrow left icon
Product type Paperback
Published in Aug 2018
Publisher Packt
ISBN-13 9781789342055
Length 214 pages
Edition 1st Edition
Languages
Concepts
Arrow right icon
Author (1):
Arrow left icon
Kassandra Perch Kassandra Perch
Author Profile Icon Kassandra Perch
Kassandra Perch
Arrow right icon
View More author details
Toc

Table of Contents (14) Chapters Close

Preface 1. Setting Up Your Development Environment FREE CHAPTER 2. Creating Your First Johnny-Five Project 3. Building Interactive Projects with RGB LED 4. Bringing in Input with Buttons 5. Using a Light Sensor to Create a Night-Light 6. Using Motors to Move Your Project 7. Using Servos for Measured Movement 8. The Animation Library 9. Getting the Information You Need 10. Using MQTT to Talk to Things on the Internet 11. Building a NodeBots Swarm 12. Assessments 13. Other Books You May Enjoy

What is the Raspberry Pi?

So, now you've got this green, credit-card-sized object with a bunch of ports that you recognize, and a bunch of pins, as shown in the following diagram. You can see some chips, and some parts you might not recognize. Before we talk about the power contained in this rather inconspicuous board, we need to clear up some vocabulary that we'll be using throughout the book:

Microcontrollers

Microcontroller is a term that encapsulates a bunch of devices. It's a term used to describe a device that contains a processor, memory, and input/output peripherals (or ways to interact with those peripherals) that is meant for a particular type of task. One extremely common microcontroller is the Arduino Uno, and the Raspberry Pi technically falls into this category as well.

General-Purpose Input/Output (GPIO) pins

Microcontrollers interface with devices such as sensors, LEDs, and buttons using electrical signals that are sent and received through pins designed for input and/or output signals. These pins can be broken into multiple subcategories, as we'll find out in subsequent chapters, but you can address them as GPIO pins as a whole. We'll use that abbreviation throughout the book.

Debian and Raspbian

Debian is a distribution of Linux that is considered extremely user friendly for those new to using Linux. It contains many utilities that are commonly used while working with Linux preinstalled, and is compatible with a lot of the peripherals that you would use with a computer, such as Wi-Fi cards and USB devices.

Raspbian is a modified version of Debian specifically designed to run on Raspberry Pi devices. There are drivers for the GPIO pins, USB Wi-Fi devices, and expansion slots on the Pi that allow you to attach a specific display and camera. 

There are two flavors of Raspbian—Raspbian Full and Raspbian Lite. Full has a graphical desktop with programs aimed at educational programming and development. Lite (which we will be using for the projects in this book) only has a command-line interface, but still has full functionality when it comes to Raspberry Pi peripherals. As of the time of writing, the current version of Raspbian is 4.14, nicknamed Stretch.

Johnny-Five and Raspi-IO

Back in 2012, Rick Waldron wrote a node-serialport program to operate an Arduino Uno with Node.js, and formed a library around it called Johnny-Five. Since then, the Johnny-Five library has grown to over 100 contributors, and can control over 40 platforms, including the Raspberry Pi! It can also control many kinds of sensors and peripherals that you can use to create the robotics project you've been dreaming of in Node.js!

One of the ways the Johnny-Five library has grown to support so many platforms is by creating what are called IO plugins. You create an IO plugin for each type of board you wish to control. For example, we will be installing and using the Raspi-IO plugin to use Johnny-Five with the Raspberry Pi.

What is great about this system is that the code you write in this book can be used on any other platform that Johnny-Five supports (you just need to change PIN numbers)! Writing code for Node.js botnets is much easier when you're using the same APIs for any devices you might use.

So, the Pi is technically a microcontroller...

Let's get back to the question of what the Raspberry Pi is. In short, it is a microcontroller. It has dozens of GPIO pins and can be used to interface with many physical peripherals in order to achieve specialized tasks. The low cost and small size allows the Raspberry Pi to be a versatile device, but the power involved allows you to use it for tasks that other microcontrollers may not pack the punch for.

...but it is also a computer!

An interesting fact about the Raspberry Pi is that, while it is a microcontroller, it can also be used as a fully fledged computer! While it certainly isn't the most powerful hardware, with full Raspbian installed, a Raspberry Pi attached to a monitor, keyboard, and mouse creates a great machine for kids and adults to learn programming on! The original intent of the Raspberry Pi was to create a low-cost educational machine to teach programming, and it exceeded every expectation in that regard. The fact that it's also a great microcontroller for the world of makers is a great bonus!

You have been reading a chapter from
Hands-On Robotics with JavaScript
Published in: Aug 2018
Publisher: Packt
ISBN-13: 9781789342055
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 €18.99/month. Cancel anytime