Browse Source

Actualizaciones finales

Funciones de escritura y lectura de datos en ambos sensores y transistores
master
parent
commit
258181bbad
1 changed files with 13 additions and 5 deletions
  1. +13
    -5
      lecturaArduino/lecturaArduino.ino

+ 13
- 5
lecturaArduino/lecturaArduino.ino View File

@ -1,6 +1,7 @@
#define in1 A0
#define in2 A1
#define out1 6
#define out2 7
float temp1, lectura1, temp2, lectura2;
String estado;
@ -10,25 +11,32 @@ void setup() {
pinMode(in1, INPUT);
pinMode(in2, INPUT);
pinMode(out1, OUTPUT);
pinMode(out2, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
lectura1 = analogRead(in1);
lectura2 = analogRead(in2);
temp1 = (lectura1 * 5000 / 1023 / 10) - 30;
temp2 = (lectura2 * 5000 / 1023 / 10) + 40; //Este debe de ser -40 pero está así para las pruebas
temp1 = (lectura1 * 5000 / 1023 / 10) - 33;
temp2 = (lectura2 * 5000 / 1023 / 10) - 37;
Serial.println(temp1);
Serial.println(temp2);
if(Serial.available()>0){
estado = Serial.readString();
if(estado == "on"){
if(estado == "on1"){
digitalWrite(out1, HIGH);
}
else if(estado == "off"){
else if(estado == "off1"){
digitalWrite(out1, LOW);
}
else if(estado == "on2"){
digitalWrite(out2, HIGH);
}
else if(estado == "off2"){
digitalWrite(out2, LOW);
}
}
delay(200);
delay(100);
}

Loading…
Cancel
Save