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.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 4:60e7e1c1d1d8
- Parent:
- 3:46ea1b20397d
- Child:
- 5:32434b497a9b
--- a/main.cpp Fri May 10 10:24:01 2019 +0000 +++ b/main.cpp Fri May 17 09:25:04 2019 +0000 @@ -16,6 +16,7 @@ void interrupt_lidar_rx(void); + float distance(float x_1, float x_2, float y_1, float y_2) { // Fonction qui renvoie la distance entre deux points (norme 2) @@ -84,6 +85,17 @@ return pwm; } +void afficher_lidar(int *tableau_distances) +{ + //Affiche les données du lidar dans la liaison série + int angle; + for(angle=0;angle<360;angle++){ + float distance = tableau_distances[angle]; + pc.printf("%i,%f\n\r",angle,distance); + + } +} + int main(){ pc.printf("\r-------------------------\n\r"); @@ -91,7 +103,6 @@ float dir[2]; // direction float pwm_direction_value; - pc.printf("%f", cos(3.141592/4)); int i; @@ -119,8 +130,9 @@ lidar.attach(&interrupt_lidar_rx, Serial::RxIrq); while (1){ - printf("pwm_moteur = %f, pwm_direction = %f", pwm_moteur, pwm_direction); - + //printf("pwm_moteur = %f, pwm_direction = %f", pwm_moteur, pwm_direction); + afficher_lidar(tableau_distance); + update_direction(tableau_distance, dir); // mise à jour à la direction pwm_direction_value = angle_servo(dir); // calcul du pwm