Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. // Cadavre exquis musical
  2.  
  3. // matos : 2nema 17 + Arduino + shield CNC
  4. // + 2 capteurs à chaque extrémité pour dire si le rouleau de papier est quasi-fini.
  5. // Quel capteur ?
  6.  
  7. // Objectif final
  8. // Le papier traceur s'enroule(M1)/se déroule(M2) dans un sens
  9. // pendant random temps1(x,x') et s'arrête temps random (y,y')
  10.  
  11. // SI un détecteur capte la fin du rouleau, l'action s'effectue dans l'autre sens
  12.  
  13.  
  14. // defines pins numbers
  15. const int stepPinM1 = 2;
  16. const int dirPinM1 = 5;
  17. const int stepPinM2 = 4;
  18. const int dirPinM2 = 7;
  19.  
  20. const int enabled = 8;
  21.  
  22.  
  23. void setup() {
  24. // Sets the two pins as Outputs
  25. pinMode(stepPinM1, OUTPUT);
  26. pinMode(dirPinM1, OUTPUT);
  27. pinMode(stepPinM2, OUTPUT);
  28. pinMode(dirPinM2, OUTPUT);
  29. pinMode(enabled, OUTPUT);
  30.  
  31. digitalWrite(enabled,LOW);
  32.  
  33. }
  34. void loop() {
  35.  
  36. int temps=random(0,10);
  37. int nb_croq=random(600,2000);
  38.  
  39. digitalWrite(dirPinM1, HIGH);
  40. digitalWrite(dirPinM2, HIGH);
  41.  
  42. for (int x = 0; x < nb_croq; x++) {
  43. digitalWrite(stepPinM1, HIGH);
  44. digitalWrite(stepPinM2, HIGH);
  45. delay(1);
  46. digitalWrite(stepPinM1, LOW);
  47. digitalWrite(stepPinM2, LOW);
  48.  
  49. delay(1);
  50. }
  51. delay(temps);
  52.  
  53.  
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement