Advertisement
peko

wifi arduino code

Oct 21st, 2015
7,321
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. int bojler = 2;
  2. int vrata = 3;
  3. int sostojba = 0;
  4.  
  5. void setup() {
  6. // initialize serial communication at 9600 bits per second:
  7. Serial.begin(9600);
  8. pinMode(bojler, OUTPUT);
  9. pinMode(vrata, OUTPUT);
  10. }
  11.  
  12. // the loop routine runs over and over again forever:
  13. void loop() {
  14. digitalWrite(vrata, LOW);
  15. int pom1 = analogRead(A0);
  16. int pom2 = analogRead(A1);
  17. float bojlerV = pom1 * (5.0 / 1023.0);
  18. float vrataV = pom2 * (5.0 / 1023.0);
  19.  
  20.  
  21. if (bojlerV<2)
  22. {
  23. digitalWrite(bojler, HIGH);
  24. }
  25. else if (bojlerV>3)
  26. {
  27. digitalWrite(bojler, LOW);
  28. }
  29.  
  30. if (vrataV<2)
  31. {
  32. sostojba = 0;
  33. }
  34. else if (vrataV>3)
  35. {
  36. sostojba++;
  37. }
  38. if (sostojba==10)
  39. {
  40. sostojba = 2;
  41. }
  42. if (sostojba==1)
  43. {
  44. digitalWrite(vrata, HIGH);
  45. delay(2000);
  46. digitalWrite(vrata, LOW);
  47. }
  48.  
  49. delay(250);
  50. Serial.print("Bojler napon: ");
  51. Serial.println(bojlerV);
  52. Serial.print("Vrata napon: ");
  53. Serial.println(vrataV);
  54. Serial.print("Sostojba: ");
  55. Serial.println(sostojba);
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement