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.

42 lines
911 B

  1. #define in1 A0
  2. #define in2 A1
  3. #define out1 6
  4. #define out2 7
  5. float temp1, lectura1, temp2, lectura2;
  6. String estado;
  7. void setup() {
  8. // put your setup code here, to run once:
  9. Serial.begin(9600);
  10. pinMode(in1, INPUT);
  11. pinMode(in2, INPUT);
  12. pinMode(out1, OUTPUT);
  13. pinMode(out2, OUTPUT);
  14. }
  15. void loop() {
  16. // put your main code here, to run repeatedly:
  17. lectura1 = analogRead(in1);
  18. lectura2 = analogRead(in2);
  19. temp1 = (lectura1 * 5000 / 1023 / 10) - 33;
  20. temp2 = (lectura2 * 5000 / 1023 / 10) - 37;
  21. Serial.println(temp1);
  22. Serial.println(temp2);
  23. if(Serial.available()>0){
  24. estado = Serial.readString();
  25. if(estado == "on1"){
  26. digitalWrite(out1, HIGH);
  27. }
  28. else if(estado == "off1"){
  29. digitalWrite(out1, LOW);
  30. }
  31. else if(estado == "on2"){
  32. digitalWrite(out2, HIGH);
  33. }
  34. else if(estado == "off2"){
  35. digitalWrite(out2, LOW);
  36. }
  37. }
  38. delay(100);
  39. }