Skip to content

Instantly share code, notes, and snippets.

@wero1414
Created December 17, 2015 02:13
Show Gist options
  • Save wero1414/552c79268f8887a2ab06 to your computer and use it in GitHub Desktop.
Save wero1414/552c79268f8887a2ab06 to your computer and use it in GitHub Desktop.
#include <SoftwareSerial.h>
SoftwareSerial BT1(2, 3); // RX | TX
String W =" ";
char w ;
char A;
char R;
#define SSID "Contreraslink"
#define PASS "contrerasflores"
void setup()
{ Serial.begin(9600);
BT1.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
BT1.println("AT+RST");
delay(500);
BT1.println("AT+CWJAP="SSID","PASS"");
delay(1000);
BT1.println("AT+CIPMUX=1");
delay(500);
BT1.println("AT+CIPSERVER=1,80");
}
void loop()
{
////////////uso de Arduino como FTDI////////////////////////
if (BT1.available())
{ w = BT1.read() ;
Serial.print(w);
W = W + w ;
}
if (Serial.available())
{ char s = Serial.read();
BT1.print(s);
}
////////////////inicio de lectura al entrar a la direccion IP////////////////////////////////
if ( w == '\n') // Sin han pulsado intro
{ if ( W.indexOf("azul") > 0 ) // Comprobamos si A esta incluido en el string
{ digitalWrite( 13, !digitalRead(13)) ;
}
if ( W.indexOf("rojo") > 0 ) // Comprobamos si R esta incluido en el string
{ digitalWrite( 12, !digitalRead(12)) ;
}
W = "" ;
w = ' ' ;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment