I'm having trouble running this code in conjunction with a physical button on blynk, I've tried it in several ways, I'm about to give up, can anyone help me? follow code below
Note: sorry for the errors, I don't speak English and I used google translator to ask for help, thank you for your attention.
define pinSentido1MotorA 32
define pinSentido2MotorA 33
const int TCPORTA = T4;
int BTP = 26;
int fimdecursoF = 15;
int fimdecursoA = 4;
const int sensibilidade = 55;
int touchValue;
//recupera a distância atual lida pelo sensor
touchValue = touchRead(TCPORTA);
int aberta = digitalRead(fimdecursoA);
int fechada = digitalRead(fimdecursoF);
int botao = digitalRead(BTP);
Serial.print("Bota :");
Serial.println(botao);
Serial.println(touchValue);
Serial.print("Fim de curso porta aberta: ");
Serial.println(aberta);
Serial.print("Fim de curso porta fechada: ");
Serial.println(fechada);
delay(250);
Blynk library version: [1.0] IDE: [Arduino] IDE version: [1.83] Board type: [Esp32] Additional modules: [...]
I'm having trouble running this code in conjunction with a physical button on blynk, I've tried it in several ways, I'm about to give up, can anyone help me? follow code below
Note: sorry for the errors, I don't speak English and I used google translator to ask for help, thank you for your attention.
define pinSentido1MotorA 32
define pinSentido2MotorA 33
const int TCPORTA = T4; int BTP = 26; int fimdecursoF = 15; int fimdecursoA = 4; const int sensibilidade = 55; int touchValue;
void setup() {
Serial.begin(115200); pinMode(BTP, INPUT); pinMode(pinSentido1MotorA, OUTPUT); pinMode(pinSentido2MotorA, OUTPUT); pinMode(fimdecursoF, INPUT); pinMode(fimdecursoA, INPUT); digitalWrite(pinSentido1MotorA, HIGH); digitalWrite(pinSentido2MotorA, HIGH);
}
void loop() {
//recupera a distância atual lida pelo sensor touchValue = touchRead(TCPORTA); int aberta = digitalRead(fimdecursoA); int fechada = digitalRead(fimdecursoF); int botao = digitalRead(BTP); Serial.print("Bota :"); Serial.println(botao); Serial.println(touchValue); Serial.print("Fim de curso porta aberta: "); Serial.println(aberta); Serial.print("Fim de curso porta fechada: "); Serial.println(fechada); delay(250);
if ((digitalRead(BTP)== HIGH) && (touchValue < sensibilidade) && (fechada == LOW) && (aberta == HIGH)) { Serial.println("Abre a Porta"); digitalWrite(pinSentido1MotorA, LOW); digitalWrite(pinSentido2MotorA, HIGH); }
}