Search icon CANCEL
Subscription
0
Cart icon
Cart
Close icon
You have no products in your basket yet
Save more on your purchases!
Savings automatically calculated. No voucher code required
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Programming the BeagleBone

You're reading from  Programming the BeagleBone

Product type Book
Published in Jan 2016
Publisher
ISBN-13 9781784390013
Pages 180 pages
Edition 1st Edition
Languages

Table of Contents (21) Chapters

Programming the BeagleBone
Credits
About the Author
Acknowledgment
About the Reviewers
www.PacktPub.com
Preface
1. Cloud9 IDE 2. Blinking Onboard LEDs 3. Blinking External LEDs 4. Controlling LED Using a Push Button 5. Reading from Analog Sensors 6. PWM – Writing Analog Information 7. Internet of Things with BeagleBone 8. Physical Computing in Python 9. UART, I2C, and SPI Programming 10. Internet of Things using Python GPIO Control in Bash BeagleBone Capes
Pinmux and the Device Tree Index

Program for creating new Node.js HTTP server


To control BeagleBone from the Internet we need to run an HTTP server on it. BeagleBone already has Node.js running as the HTTP server to be able to run Cloud9 on port 3000. There are built-in Node.js HTTP interfaces that can be used to create a new HTTP server on a specified port number. Once created, this server listens to HTML queries on the specified port. On request, it sends an HTML file to the client. The client browser renders this HTML file. So, we have to write JavaScript code to run the Node.js HTTP server and write an HTML file to be displayed. Let's create a HTML file first.

HTML code

Open Cloud9 IDE and open a new file tab. Write the following code in it and save it as iot.html.

The code for iot.html is as follows:

<!DOCTYPE html>
<html>
<body>
  <h1>Beaglebone IoT</h1>
  <h2><a href="/led.html">LED</a></h2>
  <h2><a href="/servo.html">Servo</a></h2>
</body...
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}