Paso 4: Sketch de Arduino
int ledblue = 2;
int tx = 1;
int rx = 0;
char inSerial [15];
void setup() {Serial.begin(9600);
pinMode (ledblue, salida);
pinMode (tx, salida);
pinMode (rx, entrada);
allpinslow();
}
void loop()
{int i = 0;
int m = 0;
Delay(500);
Si (Serial.available() > 0) {mientras que (Serial.available() > 0) {inSerial[i]=Serial.read();
i ++; }
inSerial [i] = '\0';
Check_Protocol(inSerial); }}
void allpinslow() {digitalWrite (ledblue, HIGH);
digitalWrite (ledblue, bajo); } void Check_Protocol (char inStr[]) {int i = 0;
int m = 0;
Serial.println(inStr);
if(!strcmp(inStr,"2OFF")) {//Led de allpinslow();
digitalWrite (ledblue, bajo); Serial.println ("azul apagado");
para (m = 0; m < 11; m ++) {inStr [m] = 0;} i = 0;} if(!strcmp(inStr,"2on")) {//Led de allpinslow();
digitalWrite (ledblue, HIGH);
Serial.println ("azul de"); para (m = 0; m < 11; m ++) {inStr [m] = 0;} i = 0;} else {para (m = 0; m < 11; m ++) {inStr [m] = 0;} i = 0;
}}