Last active
April 30, 2017 22:38
-
-
Save valdiney/b77d83fde6699843479473d8597fe071 to your computer and use it in GitHub Desktop.
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
// Realiza um disparo via Ajax para o endereço do meu NodeMcu | |
var led_controle = function(status) { | |
var xmlhttp = new XMLHttpRequest(); | |
var set_status = "http://192.168.0.106/?function=" + status; | |
xmlhttp.open("GET", set_status); | |
xmlhttp.send(); | |
} | |
// Acessa os botões e passando as nossas diretivas de ligar ou desligar o led | |
var led = function() { | |
var ligar = document.querySelector(".ligar"); | |
ligar.onclick = function() { | |
led_controle("led5_on"); | |
} | |
var desligar = document.querySelector(".desligar"); | |
desligar.onclick = function() { | |
led_controle("led5_off"); | |
} | |
} | |
window.onload = function() { | |
// Chama a função led | |
led(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment