« Micro contrôleurs AVR/Travail pratique/Télécommande NRF24L01 pour Robot » : différence entre les versions

Contenu supprimé Contenu ajouté
Ligne 1 105 :
 
3°) '''Écrire''' la partie de programme qui calcule cas, Dpwm, pwm, pwmD et pwmG. Pour laisser de la place en RAM, les variables deltaPWM et Dpwm seront fusionnées en une seule variable.
 
 
 
 
 
{{Solution|contenu=
Ligne 1 180 ⟶ 1 176 :
 
<syntaxhighlight lang="C">
ntint main() {
int16_t joystick_x,joystick_y,pwmD=60,pwmG,pwm,deltaPWM;
uint8_t rx_buffer[RX_PLOAD_WIDTH],status1,cas=0;
Ligne 1 205 ⟶ 1 201 :
joystick_y = (rx_buffer[1]<<8)+rx_buffer[0];
joystick_x = (rx_buffer[3]<<8)+rx_buffer[2];
//serialWrite16Deci(joystick_x);serialWrite(' ');serialWrite('-');serialWrite(' ');
//serialWrite16Deci(joystick_y);
//serialWrite(0x0D);serialWrite(0x0A);
// question 3° Exo 7
pwm = joystick_y-513;
// calcul de deltaPWM
deltaPWM = joystick_x-504;