Heating system interface for communication with Arduino and data graphing
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
789 B

  1. #define in1 A0
  2. #define in2 A1
  3. #define out1 6
  4. float temp1, lectura1, temp2, lectura2;
  5. String estado;
  6. void setup() {
  7. // put your setup code here, to run once:
  8. Serial.begin(9600);
  9. pinMode(in1, INPUT);
  10. pinMode(in2, INPUT);
  11. pinMode(out1, OUTPUT);
  12. }
  13. void loop() {
  14. // put your main code here, to run repeatedly:
  15. lectura1 = analogRead(in1);
  16. lectura2 = analogRead(in2);
  17. temp1 = (lectura1 * 5000 / 1023 / 10) - 30;
  18. temp2 = (lectura2 * 5000 / 1023 / 10) + 40; //Este debe de ser -40 pero está así para las pruebas
  19. Serial.println(temp1);
  20. Serial.println(temp2);
  21. if(Serial.available()>0){
  22. estado = Serial.readString();
  23. if(estado == "on"){
  24. digitalWrite(out1, HIGH);
  25. }
  26. else if(estado == "off"){
  27. digitalWrite(out1, LOW);
  28. }
  29. }
  30. delay(200);
  31. }