A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://gist.github.com/MrYsLab/fc6d9def21832f4b743b below:

pymata_aio_html_example · GitHub

Last active April 16, 2018 13:28

Clone this repository at <script src="https://gist.github.com/MrYsLab/fc6d9def21832f4b743b.js"></script>

Save MrYsLab/fc6d9def21832f4b743b to your computer and use it in GitHub Desktop.

pymata_aio_html_example

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>pymata_aio</title> <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <script src="http://code.jquery.com/jquery-1.10.2.js"></script> <script src="http://code.jquery.com/ui/1.11.4/jquery-ui.js"></script> </head> <body> <h2>Press A Button To Activate Pin 6 PWM Controlled LED</h2> <input id="ledOn" type="button" value="On" onclick="ledOn();"/> &nbsp; <input id="ledOff" type="button" value="Off" onclick="ledOff();"/> <script> // connect to the server var ipAddress = "localhost"; var ipPort = "9000"; var inputMode = "0"; var outputMode = "1"; var analogMode = "2"; var pwmMode = "3"; var socket = new WebSocket('ws://' + ipAddress + ':' + ipPort); var pin_mode = ""; var pin = ""; var outputValue = ""; // Socket handlers socket.onopen = function (event) { $("#connected").text('PyMata IoT Has Successfully Connected'); }; socket.onclose = function (event) { alert("The socket has closed! Did you start the server?"); }; socket.onmessage = function (message) { // put your code that handles incoming messages from pymata_aio here. console.log('got message' + message.data); }; var msg; // turn the led on function ledOn() { // create a set pin mode message and send it to the server msg = JSON.stringify({"method": "set_pin_mode", "params": ["6", pwmMode]}); socket.send(msg); // set the pin to 128 msg = JSON.stringify({"method": "analog_write", "params": ["6", "128"]}); socket.send(msg); } function ledOff() { // create a set pin mode message and send it to the server msg = JSON.stringify({"method": "set_pin_mode", "params": ["6", pwmMode]}); socket.send(msg); // set the pin to zero msg = JSON.stringify({"method": "analog_write", "params": ["6", "0"]}); socket.send(msg); } </script> </body> </html>

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4