Pololu-Romi-32U4-Carte-Servo

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche

Contrôler des servos

It is possible to modify the Servo library that comes with the Arduino IDE to use Timer 3 instead of Timer 1 with an ATmega32U4 based controller like the Romi 32U4. The modified Servo library does not interfere with Romi32U4Motors, making it possible to simultaneously control servos and the motors.

  1. First, you will need to locate the Arduino IDE’s Servo library, and find the file inside it named ServoTimers.h. For the 1.6.x versions of the IDE, this file can be found in libraries/Servo/src/avr/ServoTimers.h. If you are using Mac OS X, you will need to right-click on the Arduino IDE icon and select “Show Package Contents” to see the files inside.
  2. Open ServoTimers.h in a text editor.
  3. Locate the following lines of code in ServoTimers.h:
    #elif defined(__AVR_ATmega32U4__)  
    #define _useTimer1 
    typedef enum { _timer1, _Nbr_16timers } timer16_Sequence_t ;

  1. The lower two lines of code specify that the library should use Timer 1. To use Timer 3 instead, just change _useTimer1 to _useTimer3 and _timer1 to _timer3.
  2. Save the file.

The Arduino IDE will automatically incorporate your modifications to the Servo library. The next time you compile a sketch for an ATmega32U4 based controller that uses the Servo library, it will use Timer 3 instead of Timer 1.



Basé sur "Guide utilisateur de la carte de contrôle Romi 32U4" de Pololu (https://www.pololu.com/docs/0J69) - Traduit en Français par shop.mchobby.be CC-BY-SA pour la traduction
Toute copie doit contenir ce crédit, lien vers cette page et la section "crédit de traduction". Traduit avec l'autorisation expresse de Pololu (www.pololu.com)

Based on "Pololu Romi 32U4 Control Board User’s Guide" from Pololu (https://www.pololu.com/docs/0J69) - Translated to French by shop.mchobby.be CC-BY-SA for the translation
Copies must includes this credit, link to this page and the section "crédit de traduction" (translation credit). Translated with the Pololu's authorization (www.pololu.com)