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

Contenu supprimé Contenu ajouté
Ligne 1 106 :
<big>'''Solution non vérifiée donc à vérifier au plus vite !'''</big>
<syntaxhighlight lang="C">
#define MAXPWM 100
// question 2°
void deplaceToi(int16_t pwmD, int16_t pwmG) {
Ligne 1 145 ⟶ 1 146 :
 
int main() {
uint16_t joystick_x,joystick_y,pwmD,pwmG,pwm,deltaPWM;
uint8_t rx_buffer[RX_PLOAD_WIDTH],status1,cas=0;
// setup
Ligne 1 160 ⟶ 1 161 :
joystick_x = (rx_buffer[1]<<8)+rx_buffer[0];
joystick_y = (rx_buffer[3]<<8)+rx_buffer[2];
pwm = yjoystick_y-513;
// calcul de deltaPWM
deltaPWM = xjoystick_x-504;
// gestion de différentes possibilités
if (pwm > 30) cas |= 0x08; else cas &= 0x07;