Différences
Ci-dessous, les différences entre deux révisions de la page.
| 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' | ||
| + | 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, | ||
| + | pinMode(stepPin, | ||
| + | pinMode(dirPin, | ||
| + | |||
| + | btn_prev = digitalRead(btnPin); | ||
| + | } | ||
| + | void loop() | ||
| + | { | ||
| + | |||
| + |  | ||
| + | |||
| + | if (btn == LOW && btn_prev == HIGH) | ||
| + | { | ||
| + | //clockwise | ||
| + | digitalWrite(dirPin, | ||
| + | |||
| + | // Spin motor | ||
| + | for(int x = 0; x < stepsPerRevolution; | ||
| + | { | ||
| + | digitalWrite(stepPin, | ||
| + | delayMicroseconds(stepDelay); | ||
| + | digitalWrite(stepPin, | ||
| + | delayMicroseconds(stepDelay); | ||
| + | } | ||
| + | delay(1000); | ||
| + | } | ||
| + | |||
| + | btn_prev = digitalRead(btnPin); | ||
| + |  | ||
| + | } | ||
| + | </ | ||
| ===== Photos et médias===== | ===== Photos et médias===== | ||
| Code pour afficher les images du projet : | Code pour afficher les images du projet : | ||