Arduino - no puedo activar los relays

 
Vista:

no puedo activar los relays

Publicado por Noel (1 intervención) el 04/03/2020 01:52:47
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <Filters.h>
float testFrequency = 60;                     // Frecuencia (Hz)
float windowLength = 40.0/testFrequency;     // promedio de la señal
#include <Wire.h>
int Sensor = 0; //A0
int Relay1 = 13;
int Relay2 = 10;
int Relay3 = 11;
 
float intercept = -0.04; // to be adjusted based on calibration testing
float slope = 0.0405; // to be adjusted based on calibration testing
float volts; // Voltage
 
unsigned long periodo = 1000;
unsigned long tiempoAnterior = 0;
 
 
void setup() {
  Serial.begin(9600);
 
  pinMode (Relay1 , OUTPUT); // salida relay1
  pinMode (Relay2 , OUTPUT);  //salida relay2
  pinMode (Relay3 , OUTPUT); //salida relay3
 
}
 
void loop() {
 
  RunningStatistics inputStats;
  inputStats.setWindowSecs(windowLength);
 
  while(true) {
    Sensor = analogRead(A0);  //Leer pin Analógico
    inputStats.input(Sensor);
    if((unsigned long)(millis() - tiempoAnterior) >= periodo) {
      volts = intercept + slope * inputStats.sigma(); //offset y amplitud
      volts = volts*(40.3231);                        //calibración
      Serial.print("\tVoltage: ");
      Serial.println(volts);
      tiempoAnterior = millis();
 
      if ((float) volts>5);
      digitalWrite (Relay1 , HIGH);
 
      if (volts >5<33);
      digitalWrite (Relay2 , HIGH);
      if (volts >34<70);
      digitalWrite (Relay3 , HIGH);
      digitalWrite (Relay2 , LOW);
      if (volts >71<133);
      digitalWrite (Relay3 , HIGH);
      digitalWrite (Relay2 , HIGH);
 
 
 
 
    }
  }
 
}
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder
sin imagen de perfil
Val: 12
Ha aumentado 1 puesto en Arduino (en relación al último mes)
Gráfica de Arduino

no puedo activar los relays

Publicado por Eros Llorens Sala (24 intervenciones) el 24/04/2020 22:31:18
Quita el ; de los if y pon llaves"{" a los if. Creo que es eso. Si no es eso contacta conmigo por mensaje para solucionarlo.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar