Testeur.ino 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. #include "My_Eeprom.h"
  2. #include <EEPROM.h>
  3. #include "Testeur.h"
  4. void setup() {
  5. Serial.begin(115200);
  6. pinMode(pinBRAS1, INPUT);
  7. pinMode(pinBRAS2, INPUT);
  8. pinMode(pinOSMOL, INPUT);
  9. pinMode(pinCHAUF, INPUT);
  10. pinMode(pinECUME, INPUT);
  11. pinMode(pinREMON, INPUT);
  12. pinMode(pinTECBA,OUTPUT);
  13. pinMode(pinTECHA,INPUT);
  14. pinMode(pinCUVAU,INPUT);
  15. pinMode(pinRESBA,INPUT);
  16. attachInterrupt(digitalPinToInterrupt(pinBRAS1), fc_BRAS1, CHANGE); //CHANGE, RISING,FALLING
  17. attachInterrupt(digitalPinToInterrupt(pinBRAS2), fc_BRAS2, CHANGE); //CHANGE, RISING,FALLING
  18. attachInterrupt(digitalPinToInterrupt(pinOSMOL), fc_OSMO, CHANGE); //CHANGE, RISING,FALLING
  19. attachInterrupt(digitalPinToInterrupt(pinCHAUF), fc_CHAUFF, CHANGE); //CHANGE, RISING,FALLING
  20. attachInterrupt(digitalPinToInterrupt(pinECUME), fc_ECUM, CHANGE); //CHANGE, RISING,FALLING
  21. attachInterrupt(digitalPinToInterrupt(pinREMON), fc_REMO, CHANGE); //CHANGE, RISING,FALLING
  22. randomSeed(analogRead(0));
  23. }
  24. void loop() {
  25. NiveauBas();
  26. if(digitalWrite(pinTECHA)){
  27. Enregistre(TEHON);
  28. }
  29. if(digitalWrite(pinCUVAU)){
  30. Enregistre(CUHON);
  31. }
  32. if(digitalWrite(pinRESBA)){
  33. Enregistre(REBON);
  34. }
  35. delay(DELAYLOOP);
  36. }
  37. void NiveauBas(void){
  38. if (random(60*60*1000))/DELAYLOOP)==1){
  39. digitalWrite(pinTECBA,HIGH);
  40. Enregistre(TEBON);
  41. //Rajouter un test pour la non remonter du niveau d'eau
  42. delay(random(1000,2000));
  43. digitalWrite(pinTECBA,LOW);
  44. Enregistre(TEBOF);
  45. }
  46. }
  47. void fc_BRAS1() {
  48. if(digitalRead(pinBRAS1)){
  49. Enregistre(BR1ON);
  50. }
  51. else{
  52. Enregistre(BR1OF);
  53. }
  54. }
  55. void fc_BRAS2() {
  56. if(digitalRead(pinBRAS2)){
  57. Enregistre(BR2ON);
  58. }
  59. else{
  60. Enregistre(BR2OF);
  61. }
  62. }
  63. void fc_OSMO() {
  64. if(digitalRead(pinOSMOL)){
  65. Enregistre(OSMON);
  66. }
  67. else{
  68. Enregistre(OSMOF);
  69. }
  70. }
  71. void fc_CHAUFF() {
  72. if(digitalRead(pinCHAUF)){
  73. Enregistre(CHAON);
  74. }
  75. else{
  76. Enregistre(CHAOF);
  77. }
  78. }
  79. void fc_ECUM() {
  80. if(digitalRead(pinECUME)){
  81. Enregistre(ECUON);
  82. }
  83. else{
  84. Enregistre(ECUOF);
  85. }
  86. }
  87. void fc_REMO() {
  88. if(digitalRead(pinREMON)){
  89. Enregistre(REMON);
  90. }
  91. else{
  92. Enregistre(REMOF);
  93. }
  94. }