1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
   | // zoom
#define zoomDirPin 2
#define zoomStepPin 3    
#define boutonZoomInPin 10
#define boutonZoomOutPin 11
#define tempoZoom 500
bool zoom = false;
 
// suivi
#define suiviDirPin 4
#define suiviStepPin 5    
#define boutonAccelererPin 6    
#define boutonRalentirPin 7
#define boutonMarchePin 8
#define boutonArretPin 9
#define normal 2080
#define rapide 1580
#define lent 2780
 
int tempo;
 
void setup() {
  pinMode(zoomDirPin, OUTPUT);
  pinMode(zoomStepPin, OUTPUT);
  pinMode(suiviDirPin, OUTPUT);
  pinMode(suiviStepPin, OUTPUT);
  pinMode(boutonZoomInPin, INPUT_PULLUP);  // L'autre cote du bouton au GND
  pinMode(boutonZoomOutPin, INPUT_PULLUP);   //         "        "        "
  pinMode(boutonAccelererPin,INPUT_PULLUP);  // L'autre cote du bouton au GND
  pinMode(boutonRalentirPin, INPUT_PULLUP);   //         "        "        "
  pinMode(boutonMarchePin, INPUT_PULLUP);
  pinMode(boutonArretPin, INPUT_PULLUP);
}
 
void loop() {
 
    if (digitalRead(boutonAccelererPin) == LOW)      // Si le bouton accelerer est pressé
      tempo = rapide;
    else if (digitalRead(boutonRalentirPin) == LOW)  // Si le bouton freiner est pressé
      tempo = lent;
    else if (digitalRead(boutonMarchePin) == LOW)    // Si le bouton marche est pressé
      tempo = normal;
    else if (digitalRead(boutonArretPin) == LOW)     // Si le bouton arrêt est pressé
      tempo = 0;
 
    if (tempo > 0) {
      digitalWrite(suiviStepPin, LOW);
      delayMicroseconds(tempo);
      digitalWrite(suiviStepPin, HIGH);
      delayMicroseconds(tempo);
    }
    if (zoom > 0 )  {
      digitalWrite(zoomStepPin, LOW);
      delayMicroseconds(tempoZoom);
      digitalWrite(zoomStepPin, HIGH);
      delayMicroseconds(tempoZoom);
      zoom = false;
    }
    if (digitalRead(boutonZoomInPin) == LOW) {     // Si le bouton Zoom In est presse
      digitalWrite(zoomDirPin, LOW);
      zoom = true;
    } else if (digitalRead(boutonZoomOutPin) == LOW) {  // Si le bouton Zoom Out est presse
      digitalWrite(zoomDirPin, HIGH);
      zoom = true;
    }
 
 
} | 
Partager