Étape 2: Le code pour Arduino Uno(Joystick)
mots, je suis passé dessus pour imprimer les lettres que l’esquisse de rover comprend.
const byte PIN_ANALOG_X = 0 ;
octet const PIN_ANALOG_Y = 1 ;
const int X_THRESHOLD_LOW = 450 ; // I avoir le vrai grand donc il y a moins de chance pour regroupés
const int X_THRESHOLD_HIGH = 550 ; mauvaise interprétation analogique.
const int Y_THRESHOLD_LOW = 450 ;
const int Y_THRESHOLD_HIGH = 550 ;
int x_position ;
int y_position ;
int x_direction ;
int y_direction ;
void setup() {}
Serial.Begin(9600) ;
}
void loop () {}
x_direction = 0 ;
y_direction = 0 ;
x_position = analogRead(PIN_ANALOG_X) ;
y_position = analogRead(PIN_ANALOG_Y) ;
Si (x_position > X_THRESHOLD_HIGH) {}
x_direction = 1 ;
} ElseIf (x_position < X_THRESHOLD_LOW) {}
x_direction = -1 ;
}
Si (y_position > Y_THRESHOLD_HIGH) {}
y_direction = 1 ;
} ElseIf (y_position < Y_THRESHOLD_LOW) {}
y_direction = -1 ;
}
Si (x_direction == -1) {}
Si (y_direction == -1) {}
Serial.println("Left-Down") ;
} ElseIf (y_direction == 0) {}
Serial.println("a") ; le A est quel est ce qui en fait aller à gauche
} else {}
y_direction == 1
Serial.println("Left-up") ;
}
} ElseIf (x_direction == 0) {}
Si (y_direction == -1) {}
Serial.println("s") ; S est pour le retour
} ElseIf (y_direction == 0) {}
Serial.println("f") ; F est pour Stop--il envoie ceci jusqu'à ce que quelque chose est envoyé
} else {}
y_direction == 1
Serial.println("w") ; W est avant
}
} else {}
x_direction == 1
Si (y_direction == -1) {}
Serial.println("right-down") ;
} ElseIf (y_direction == 0) {}
Serial.println("d") ; D a raison
} else {}
y_direction == 1
Serial.println("Right-Up") ;
}
}}