Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intel Do-It-Yourself Challenge Lab 5: Controlling Galileo from a webpage Nicolas Vailliet www.Intel-Software-Academic-Program.com paul.guermonprez@intel.com.

Similar presentations


Presentation on theme: "Intel Do-It-Yourself Challenge Lab 5: Controlling Galileo from a webpage Nicolas Vailliet www.Intel-Software-Academic-Program.com paul.guermonprez@intel.com."— Presentation transcript:

1 Intel Do-It-Yourself Challenge Lab 5: Controlling Galileo from a webpage
Nicolas Vailliet Intel Software

2 Prerequisites and objectives
We assume that: You are able to download an archive, to unzipped it and run a program under the OS you’re familiar to. You are able to read pieces of code and comments written in C-like language. Our objective are: Given a Galileo board and a laptop connected on the same network, you will be able to write node.js code to control galileo from a webpage, displayed in your laptop’s browser. In general, Our goal is to teach you a little bit of node.js, as it is one of the most employed technology in IoT.

3 Before you start

4 What do you need? Desktop OS We assume you’re under Microsoft Windows. Linux and Mac users should not have any problem to do the same. Hardware - An Intel Galileo Development Board. - The box comes with power supply and cable. - A Wi-Fi adaptor (N-2200 Mini-PCIe) - A micro SD card (8GB with the full Linux image we provide) Software - A SSH client like Putty for Windows. Mac and Linux users only need a terminal. - Set up system date to avoid certificate expiration issue - Install Galileo-io node on your Galileo board (Optional: You can install node.js on your laptop to test your program before).

5 Web LED controller demo

6 Web LED controller demo
Galileo-io module This node.js module allows you to access GPIO without dealing with files from Linux file system (and the mapping stuff). Functions have the same name as Arduino library ones. Importing this module var Galileo = require("galileo-io"); var board = new Galileo(); TurnOnLed function function turnOnLed(){ board.digitalWrite(8, 1); } A simple HTTP server var http = require('http'); http.createServer(function (req, res) { function respond() { res.writeHead(200, { "Content-Type": "text/html" }); res.end(“Hello World"); }).listen(1337);

7 Web LED controller demo
A respond function with a basic html page function respond() { res.writeHead(200, { "Content-Type": "text/html" }); res.write("<!DOCTYPE html><html><body>"); res.write("<h1>Intel Galileo web controller</h1>"); res.write("<p>Sensor value : "); res.write(sensorvalue); res.write("</p><p>LED Status : "); res.write(ledstatus); res.write("</p><p>Action</p>"); res.write("<p><input type='button' onclick='location.reload();' value='Refresh'/></p>"); res.write("<p><input type='button' onclick='window.location = \"http:// :1337/ledOn\"' value='Turn LED on'/></p>"); res.write("<p><input type='button' onclick='window.location = \"http:// :1337/ledOff\"' value='Turn LED off'/></p>"); res.write("</body></html>"); res.end(); }

8 Web LED controller demo
Looking the server-side URL to determine the command console.log("Request: " + req.url); if(req.url === "/ledOn") turnOnLed(); else if(req.url === "/ledOff") turnOffLed(); respond(); }).listen(1337); console.log('Server running at } Running the server startServer();

9 Web LED controller demo
Open your browser Access the URL : Click on buttons to test your implementation!

10 Next steps Controlling servo motors USB ports on Galileo are useful. Let’s control servo motor! Implement your own projects Want a remote for Galileo? Do it under Android! Another idea? Let’s make it!

11

12 License Creative Commons – By 3.0
You are free: to Share — to copy, distribute and transmit the work to Remix — to adapt the work to make commercial use of the work Under the following conditions: Attribution — You must attribute the work in the manner specified by the author or licensor (but not in any way that suggests that they endorse you or your use of the work). With the understanding that: Waiver — Any of the above conditions can be waived if you get permission from the copyright holder. Public Domain — Where the work or any of its elements is in the public domain under applicable law, that status is in no way affected by the license. Other Rights — In no way are any of the following rights affected by the license: Your fair dealing or fair use rights, or other applicable copyright exceptions and limitations; The author's moral rights; Rights other persons may have either in the work itself or in how the work is used, such as publicity or privacy rights. Notice — For any reuse or distribution, you must make clear to others the license terms of this work. The best way to do this is with a link to this web page.


Download ppt "Intel Do-It-Yourself Challenge Lab 5: Controlling Galileo from a webpage Nicolas Vailliet www.Intel-Software-Academic-Program.com paul.guermonprez@intel.com."

Similar presentations


Ads by Google