Advertisement
Ollivier

RF433 servo potent Emetteur

Apr 28th, 2020
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. #include <RCSwitch.h>
  2.  
  3. RCSwitch mySwitch = RCSwitch();
  4.  
  5. int brochePotentiometre = 1;
  6. int valeurPotentiometre = 0;
  7. int valeurPotentiometreMemoire = 0;
  8.  
  9. long temporisation;
  10.  
  11. bool enCours = false;
  12.  
  13. void setup() {
  14. Serial.begin(115200);
  15. // emetteur broche 10
  16. mySwitch.enableTransmit(10);
  17. temporisation = millis();
  18. }
  19.  
  20. void loop() {
  21.  
  22. valeurPotentiometre = map(analogRead (brochePotentiometre), 0, 1023, 100, 35);
  23. //if ((millis() - temporisation) > 150) {
  24. if (valeurPotentiometre != valeurPotentiometreMemoire) {
  25. enCours = true;
  26. valeurPotentiometreMemoire = valeurPotentiometre;
  27. //mySwitch.send((valeurPotentiometre + 3000), 16);
  28. temporisation = millis();
  29. } else {
  30. if (enCours == true) {
  31. mySwitch.send((valeurPotentiometre + 3000), 16);
  32. //temporisation = millis();
  33. enCours = false;
  34. } else {
  35. enCours = false;
  36. }
  37. }
  38. //}
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement