/* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/*
* File: main.c
* Author: Manuel Jiménez Heredia
* Created on: January 09th 2018
* uC: ESP32-WROOM-32
* Version: 1.0
* Description: Main programa
*
*/
/* /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\ */
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define BLINK_GPIO 14
#define I2 4
#define I1 32
#define En 21
#define I3 25
#define I4 33
#define En2 26
/* Colocar token enviado una vez que se registra en Blynk para uso de la APP */
char auth[] = "token_32Caracteres";
char ssid[] = "NOMBRE_RED";
char pass[] = "CONTRASEÑA";
BLYNK_WRITE(V1)
{
int x = param[0].asInt()*10;
int y = param[1].asInt();
int r=x+y;
if(r==-1){Serial.println("Es menos uno");}
// Do something with x and y
Serial.print("X = ");
Serial.print(x);
Serial.print("; Y = ");
Serial.println(y);
Serial.print("R = ");
Serial.println(r);
if(r==0){
digitalWrite(En,HIGH);
digitalWrite(En2,HIGH);}
else if(r==10){
digitalWrite(En,LOW);
digitalWrite(En2,LOW);
digitalWrite(I2,LOW);
digitalWrite(I1,HIGH);
digitalWrite(I4,HIGH);
digitalWrite(I3,LOW);}
else if(r==-10){
digitalWrite(En,LOW);
digitalWrite(En2,LOW);
digitalWrite(I2,HIGH);
digitalWrite(I1,LOW);
digitalWrite(I4,LOW);
digitalWrite(I3,HIGH);}
else if(r==1){
digitalWrite(En,LOW);
digitalWrite(En2,LOW);
digitalWrite(I2,LOW);
digitalWrite(I1,HIGH);
digitalWrite(I4,LOW);
digitalWrite(I3,HIGH);}
else if(r==-1){
digitalWrite(En,LOW);
digitalWrite(En2,LOW);
digitalWrite(I2,HIGH);
digitalWrite(I1,LOW);
digitalWrite(I4,HIGH);
digitalWrite(I3,LOW);}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(I2, OUTPUT);
pinMode(I1, OUTPUT);
pinMode(En, OUTPUT);
pinMode(I3, OUTPUT);
pinMode(I4, OUTPUT);
pinMode(En2, OUTPUT);
}
void loop()
{
Blynk.run();
}
/* Comment this out to disable prints and save space */
#define BLYNK_PRINT Serial
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
#define BLINK_GPIO 14
#define I2 4
#define I1 32
#define En 21
#define I3 25
#define I4 33
#define En2 26
/* Colocar token enviado una vez que se registra en Blynk para uso de la APP */
char auth[] = "token_32Caracteres";
char ssid[] = "NOMBRE_RED";
char pass[] = "CONTRASEÑA";
BLYNK_WRITE(V1)
{
int x = param[0].asInt()*10;
int y = param[1].asInt();
int r=x+y;
if(r==-1){Serial.println("Es menos uno");}
// Do something with x and y
Serial.print("X = ");
Serial.print(x);
Serial.print("; Y = ");
Serial.println(y);
Serial.print("R = ");
Serial.println(r);
if(r==0){
digitalWrite(En,HIGH);
digitalWrite(En2,HIGH);}
else if(r==10){
digitalWrite(En,LOW);
digitalWrite(En2,LOW);
digitalWrite(I2,LOW);
digitalWrite(I1,HIGH);
digitalWrite(I4,HIGH);
digitalWrite(I3,LOW);}
else if(r==-10){
digitalWrite(En,LOW);
digitalWrite(En2,LOW);
digitalWrite(I2,HIGH);
digitalWrite(I1,LOW);
digitalWrite(I4,LOW);
digitalWrite(I3,HIGH);}
else if(r==1){
digitalWrite(En,LOW);
digitalWrite(En2,LOW);
digitalWrite(I2,LOW);
digitalWrite(I1,HIGH);
digitalWrite(I4,LOW);
digitalWrite(I3,HIGH);}
else if(r==-1){
digitalWrite(En,LOW);
digitalWrite(En2,LOW);
digitalWrite(I2,HIGH);
digitalWrite(I1,LOW);
digitalWrite(I4,HIGH);
digitalWrite(I3,LOW);}
}
void setup()
{
// Debug console
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pinMode(I2, OUTPUT);
pinMode(I1, OUTPUT);
pinMode(En, OUTPUT);
pinMode(I3, OUTPUT);
pinMode(I4, OUTPUT);
pinMode(En2, OUTPUT);
}
void loop()
{
Blynk.run();
}
No hay comentarios.:
Publicar un comentario