Book Image

Intel Galileo Networking Cookbook

By : Marco Schwartz
Book Image

Intel Galileo Networking Cookbook

By: Marco Schwartz

Overview of this book

Table of Contents (15 chapters)
Intel Galileo Networking Cookbook
About the Author
About the Reviewers

Controlling pins via a web server

In this recipe, we are going to do the reverse of what we did in the previous recipe. Here, we are going to see how to control a pin from a Node.js server, just by typing a command into your browser. Let's start!

Getting ready

The hardware configuration for this recipe is relatively simple, as we just want to check that we can change the state of a pin from a Node.js server.

We will test this with a simple LED and a 220 ohm resistor. You will also need a breadboard and some male/male jumper wires.

To connect the LED to the Galileo board, first place the LED and the resistor in series on the breadboard, by connecting the longest side of the LED (the anode) to the resistor. Then, connect the other resistor pin to the Galileo pin 7, and the other side of the LED (the cathode) to the ground.

This is the final result:

How to do it...

We are now going to build a simple web server, again based on Node.js and Express, to control this LED by typing simple commands into...