gente tentei o domingo inteiro e nao consegui .
venho novamente solicitar a ajuda de vocês nesse projeto .
onde eu preciso ligar desligar um led. mas tem que pressionar para menter ligado e soltar para desligar
com esse codigo no --------pastebin -------- http://pastebin.com/KYM3eMHG
esse meu codigo está ligando e desligando basta clicar.
mas não quero clicar e sim pressionar para ligar e soltar para desligar
exemplo igual uma campainha de residencial
codigo abaixo no --------pastebin -------- http://pastebin.com/KYM3eMHG
Tags:
Oi Amanda desculpe e por causa da foto sua e do Nelson ser escura ea mesma eu confundi e não te agradeci. pensando que já avia feito.
fico muito grato pela sua dica e muito obrigado mesmo pois eu pesquisei bastante
mil desculpas foi falha minha.
O amigo leandro muito obrigado pela sua grande paciência .
e muito obrigado a todos vocês.
Leandro
Amanda
Nelson
e todos que leram mas por algum motivo não pode ajudar
mas lembrando já me ajudaram em outras
Consegui !!!!!!!!!!!!!!!!!!!!
Eu tenho um NodeMCU entao a conexao dele é bem diferente do arduino mas funciona nos 2, so fazer a conexao o resto é igual ! se não conseguir modificar o codigo pra sua shild me avisa que eu monto
segue:
#include <ESP8266WiFi.h>
const char* ssid = "seu ssid";
const char* password = "sua senha";
// Create an instance of the server
// specify the port to listen on as an argument
WiFiServer server(80);
void setup() {
Serial.begin(115200);
delay(10);
// prepare GPIO2
pinMode(2, OUTPUT);
pinMode(0, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(2, 0);
digitalWrite(0, 0);
digitalWrite(13, 0);
// Connect to WiFi network
Serial.println();
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
delay(500);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
// Start the server
server.begin();
Serial.println("Server started");
// Print the IP address
Serial.println(WiFi.localIP());
}
void loop() {
// Check if a client has connected
WiFiClient client = server.available();
if (!client) {
return;
}
// Wait until the client sends some data
Serial.println("new client");
while(!client.available()){
delay(1);
}
// Read the first line of the request
String req = client.readStringUntil('\r');
Serial.println(req);
client.flush();
// Match the request
int val;
if (req.indexOf("?f=b") != -1)
val = 0;
else if (req.indexOf("?f=a") != -1)
val = 1;
else {
Serial.println("invalid request");
client.stop();
return;
}
// Set GPIO2 according to the request
digitalWrite(2, val);
digitalWrite(0, val);
digitalWrite(13, val);
client.flush();
// Prepare the response
String s = "HTTP/1.1 200 OK\r\nContent-Type: text/html\r\n\r\n<!DOCTYPE HTML>\r\n<html>\r\nGPIO is now ";
s += (val)?"high":"low";
s += "<BODY>";
s += "<H1><center>ARDUINO PRESS BUTTON</center></H1>";
s += "<br>";
s += "<table align='center' border=10 bgcolor='green' ><th><h2><div onmousedown=mDown(this) onmouseup=mUp(this) style.bgcolor='blue';width:130px;height:30px;padding:10px;>";
s += (val)?"LIGADO":"DESLIGADO";
s += "</div></table>";
s += "<script>function mDown(obj){obj.style.bgcolor='red';obj.innerHTML='ACESO';window.location.href = '?f=a';}function mUp(obj){obj.style.bgcolor='green';obj.innerHTML='";
s += (val)?"LIGADO":"DESLIGADO";
s += "';window.location.href = '?f=b';}</script>";
s += "</BODY>";
s += "</html>\n";
// Send the response to the client
client.print(s);
delay(1);
Serial.println("Client disonnected");
// The client will actually be disconnected
// when the function returns and 'client' object is detroyed
}
Esse codigo eh seu?
nao, peguei um exemplo e mudei
eu acho que vc colocar o link da origem do codigo eh uma forma de vc reconhecer o trabalho alheio, tem como saber se a URL esta com link em algum lugar, eu ficaria contente em saber que meu trabalho tem sido usado por outros, eh o minimo que posso fazer, link da origem nada de copycat.
não consegui não esta dando varios erros rsrs.
da uma mão aqui
Boa noite moises, experimenta esse codigo,
Boa noite nelson ele não aciona o led tentei de tudo rsrs.
obrigado
como eu disse tem que mudar pro Sield, vou fazer ja posto
Moises a pagina da WEB aparece direito como na pagina que enviei? muda de cor e aparece o ACESO eo APAGADO?
Bem-vindo a
Laboratorio de Garagem (arduino, eletrônica, robotica, hacking)
© 2024 Criado por Marcelo Rodrigues. Ativado por