projets:sculpture_moteur_pas_a_pas:start

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

projets:sculpture_moteur_pas_a_pas:start [2022/05/09 14:56]
admin Créé depuis le formulaire creerunprojet
projets:sculpture_moteur_pas_a_pas:start [2022/05/09 14:56] (Version actuelle)
admin [Notes techniques et matériaux]
Ligne 17: Ligne 17:
 Liste de matériel et composants nécessaires (documents avec photo si possible...) Liste de matériel et composants nécessaires (documents avec photo si possible...)
  
 +
 +<code c+>
 +
 +#define btnPin 6
 +// Define pin connections & motor's steps per revolution
 +const int dirPin = 2;
 +const int stepPin = 3;
 +const int stepsPerRevolution = 200/3;
 +int stepDelay=4000;
 +uint8_t btn_prev;
 +void setup()
 +{
 +  // Declare pins as Outputs
 +  pinMode(btnPin, INPUT_PULLUP);
 +  pinMode(stepPin, OUTPUT);
 +  pinMode(dirPin, OUTPUT);
 +
 +  btn_prev = digitalRead(btnPin);
 +}
 +void loop()
 +{
 +
 +   uint8_t btn = digitalRead(btnPin);
 +
 + if (btn == LOW && btn_prev == HIGH)
 +  {
 +    //clockwise
 +  digitalWrite(dirPin, HIGH);
 +
 +  // Spin motor
 +  for(int x = 0; x < stepsPerRevolution; x++)
 +  {
 +    digitalWrite(stepPin, HIGH);
 +    delayMicroseconds(stepDelay);
 +    digitalWrite(stepPin, LOW);
 +    delayMicroseconds(stepDelay);
 +  }
 +  delay(1000); // Wait a second  
 +  }
 +
 +  btn_prev = digitalRead(btnPin);
 +  
 +}
 +</code>
 ===== Photos et médias===== ===== Photos et médias=====
 Code pour afficher les images du projet : Code pour afficher les images du projet :
  • projets/sculpture_moteur_pas_a_pas/start.txt
  • Dernière modification: 2022/05/09 14:56
  • de admin