Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Cadavre exquis musical
- // matos : 2nema 17 + Arduino + shield CNC
- // + 2 capteurs à chaque extrémité pour dire si le rouleau de papier est quasi-fini.
- // Quel capteur ?
- // Objectif final
- // Le papier traceur s'enroule(M1)/se déroule(M2) dans un sens
- // pendant random temps1(x,x') et s'arrête temps random (y,y')
- // SI un détecteur capte la fin du rouleau, l'action s'effectue dans l'autre sens
- // defines pins numbers
- const int stepPinM1 = 2;
- const int dirPinM1 = 5;
- const int stepPinM2 = 4;
- const int dirPinM2 = 7;
- const int enabled = 8;
- void setup() {
- // Sets the two pins as Outputs
- pinMode(stepPinM1, OUTPUT);
- pinMode(dirPinM1, OUTPUT);
- pinMode(stepPinM2, OUTPUT);
- pinMode(dirPinM2, OUTPUT);
- pinMode(enabled, OUTPUT);
- digitalWrite(enabled,LOW);
- }
- void loop() {
- int temps=random(0,10);
- int nb_croq=random(600,2000);
- digitalWrite(dirPinM1, HIGH);
- digitalWrite(dirPinM2, HIGH);
- for (int x = 0; x < nb_croq; x++) {
- digitalWrite(stepPinM1, HIGH);
- digitalWrite(stepPinM2, HIGH);
- delay(1);
- digitalWrite(stepPinM1, LOW);
- digitalWrite(stepPinM2, LOW);
- delay(1);
- }
- delay(temps);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement