Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of Deplacement by
Deplacement.cpp
00001 #include "Deplacement.h" 00002 #include "mbed.h" 00003 00004 m3pi m3piD; 00005 00006 Deplacement::Deplacement() //constructeur 00007 { 00008 00009 this->mseconds=30;// temps pour la rotation une fois valeur trouvé ne pas changer 00010 posx=0; 00011 posy=0; 00012 this->vitesse=0.1; //pointeur this 00013 } 00014 00015 void Deplacement::init(float val){ 00016 m3piD.right_motor(val); 00017 m3piD.left_motor(val); 00018 } 00019 00020 Deplacement::~Deplacement() 00021 { 00022 00023 } 00024 ///////////////////////////////////////////////////// 00025 00026 void Deplacement::setVitesse(float v) 00027 { 00028 this->vitesse=v; 00029 } 00030 00031 ///////////////////////////////////////////////////// 00032 00033 void Deplacement::tourner_droite() 00034 { 00035 int copie=0; 00036 00037 m3piD.right(this->vitesse); 00038 wait(0.9); 00039 00040 m3piD.stop(); 00041 00042 posx=copie; 00043 posx=posy; 00044 posy=-copie; 00045 00046 } 00047 00048 void Deplacement::tourner_gauche() 00049 { 00050 int copie=0; 00051 00052 m3piD.left(this->vitesse); 00053 wait(0.9); 00054 m3piD.stop(); 00055 00056 00057 posx=copie; 00058 posx=-posy; 00059 posy=copie; 00060 00061 } 00062 00063 void Deplacement::avancer(float temps) 00064 { 00065 m3piD.forward(this->vitesse); 00066 wait(temps); 00067 posy++; 00068 m3piD.stop(); 00069 } 00070 00071 void Deplacement::reculer(float temps) 00072 { 00073 m3piD.right(this->vitesse); 00074 wait(1.8); 00075 m3piD.backward(this->vitesse); 00076 wait(temps); 00077 posy--; 00078 m3piD.stop(); 00079 } 00080 00081 void Deplacement::gauche(float temps){ 00082 m3piD.left(this->vitesse); 00083 wait(0.9); 00084 avancer(temps); 00085 } 00086 00087 void Deplacement::droite(float temps){ 00088 m3piD.right(this->vitesse); 00089 wait(0.9); 00090 avancer(temps); 00091 } 00092 00093 void Deplacement::stop() 00094 { 00095 m3piD.stop(); 00096 } 00097 00098 void Deplacement::RAZ() 00099 { 00100 posx=0; 00101 posy=0; 00102 this->vitesse=0; 00103 00104 } 00105 00106 float Deplacement::getVitesse() 00107 { 00108 return(this->vitesse); 00109 } 00110 00111 int Deplacement::getPosX() 00112 { 00113 return(this->posx); 00114 } 00115 00116 int Deplacement::getPosY() 00117 { 00118 return(this->posy); 00119 } 00120 00121 void Deplacement::tourner_droite_t() 00122 { 00123 00124 m3piD.left_motor(this->vitesse); 00125 m3piD.right_motor(-(this->vitesse)); 00126 } 00127 00128 void Deplacement::quartRotation(){ 00129 m3piD.right(this->vitesse); 00130 wait(0.9); 00131 m3piD.stop(); 00132 } 00133 00134 00135 00136 00137
Generated on Thu Jul 21 2022 02:49:21 by
