Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
projets:antennes:robotized_mag_loop:index [2021/05/13 12:01] – f1sls | projets:antennes:robotized_mag_loop:index [2021/05/16 18:56] (Version actuelle) – [LIBS] f1sls | ||
---|---|---|---|
Ligne 43: | Ligne 43: | ||
{{: | {{: | ||
+ | |||
+ | {{: | ||
=== ULN2003 DATASHEET === | === ULN2003 DATASHEET === | ||
{{ : | {{ : | ||
- | ===== SCHEMATICS ===== | + | {{: |
+ | |||
+ | === ULN2003 DRIVER BOARD DATASHEET | ||
+ | {{ : | ||
+ | |||
+ | ===== STEPPER CONTROL | ||
{{: | {{: | ||
+ | |||
+ | ==== POSITION READING ==== | ||
+ | |||
+ | <WRAP center round info 60%> | ||
+ | We are using a 250k potentiometer to read the position of the stepper-motor / variable capacitor. We must avoid to go below the 0 position of the variable capacitor (fully open, minimum capacitance) and avoid to go over the 100% position of the variable capacitor (fully closed, maximum capacitance). | ||
+ | </ | ||
+ | |||
+ | {{: | ||
+ | |||
+ | {{: | ||
+ | |||
+ | |||
+ | <code cpp> | ||
+ | /* Analog Read to LED | ||
+ | * ------------------ | ||
+ | * | ||
+ | * turns on and off a light emitting diode(LED) connected to digital | ||
+ | * pin 13. The amount of time the LED will be on and off depends on | ||
+ | * the value obtained by analogRead(). In the easiest case we connect | ||
+ | * a potentiometer to analog pin 2. | ||
+ | * | ||
+ | * Created 1 December 2005 | ||
+ | * copyleft 2005 DojoDave < | ||
+ | * http:// | ||
+ | * | ||
+ | */ | ||
+ | |||
+ | int potPin = 2; // select the input pin for the potentiometer | ||
+ | int ledPin = 13; // select the pin for the LED | ||
+ | int val = 0; // variable to store the value coming from the sensor | ||
+ | |||
+ | void setup() { | ||
+ | pinMode(ledPin, | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | val = analogRead(potPin); | ||
+ | digitalWrite(ledPin, | ||
+ | delay(val); | ||
+ | digitalWrite(ledPin, | ||
+ | delay(val); | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== CODE ===== | ||
+ | ==== LIBS ==== | ||
+ | * https:// | ||
+ | ==== ARDUINO STEPPER EXAMPLES ==== | ||
+ | <code cpp> | ||
+ | /* Example sketch to control a 28BYJ-48 stepper motor with ULN2003 driver board and Arduino UNO. More info: https:// | ||
+ | |||
+ | // Include the Arduino Stepper.h library: | ||
+ | #include < | ||
+ | |||
+ | // Define number of steps per rotation: | ||
+ | const int stepsPerRevolution = 2048; | ||
+ | |||
+ | // Wiring: | ||
+ | // Pin 8 to IN1 on the ULN2003 driver | ||
+ | // Pin 9 to IN2 on the ULN2003 driver | ||
+ | // Pin 10 to IN3 on the ULN2003 driver | ||
+ | // Pin 11 to IN4 on the ULN2003 driver | ||
+ | |||
+ | // Create stepper object called ' | ||
+ | Stepper myStepper = Stepper(stepsPerRevolution, | ||
+ | |||
+ | void setup() { | ||
+ | // Set the speed to 5 rpm: | ||
+ | myStepper.setSpeed(5); | ||
+ | | ||
+ | // Begin Serial communication at a baud rate of 9600: | ||
+ | Serial.begin(9600); | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // Step one revolution in one direction: | ||
+ | Serial.println(" | ||
+ | myStepper.step(stepsPerRevolution); | ||
+ | delay(500); | ||
+ | | ||
+ | // Step one revolution in the other direction: | ||
+ | Serial.println(" | ||
+ | myStepper.step(-stepsPerRevolution); | ||
+ | delay(500); | ||
+ | } | ||
+ | </ | ||
+ | ---- | ||
+ | |||
+ | <code cpp> | ||
+ | //Includes the Arduino Stepper Library | ||
+ | #include < | ||
+ | |||
+ | // Defines the number of steps per rotation | ||
+ | const int stepsPerRevolution = 2038; | ||
+ | |||
+ | // Creates an instance of stepper class | ||
+ | // Pins entered in sequence IN1-IN3-IN2-IN4 for proper step sequence | ||
+ | Stepper myStepper = Stepper(stepsPerRevolution, | ||
+ | |||
+ | void setup() { | ||
+ | // Nothing to do (Stepper Library sets pins as outputs) | ||
+ | } | ||
+ | |||
+ | void loop() { | ||
+ | // Rotate CW slowly | ||
+ | myStepper.setSpeed(100); | ||
+ | myStepper.step(stepsPerRevolution); | ||
+ | delay(1000); | ||
+ | |||
+ | // Rotate CCW quickly | ||
+ | myStepper.setSpeed(700); | ||
+ | myStepper.step(-stepsPerRevolution); | ||
+ | delay(1000); | ||
+ | } | ||
+ | </ |