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 freescal_cup_k22f
source/main.cpp@6:a4e49784b533, 2015-01-13 (annotated)
- Committer:
- RobinN7
- Date:
- Tue Jan 13 17:03:09 2015 +0000
- Revision:
- 6:a4e49784b533
- Parent:
- 5:4d1a524433ca
- Child:
- 12:3384196374ca
ca marche pas trop mal
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RobinN7 | 0:3af30bfbc3e5 | 1 | |
RobinN7 | 0:3af30bfbc3e5 | 2 | //Bibliothéque |
RobinN7 | 0:3af30bfbc3e5 | 3 | #include "mbed.h" |
RobinN7 | 0:3af30bfbc3e5 | 4 | #include "QEI.h" |
RobinN7 | 0:3af30bfbc3e5 | 5 | #include "Gestion_Moteur.h" |
RobinN7 | 0:3af30bfbc3e5 | 6 | #include "Camera.h" |
RobinN7 | 0:3af30bfbc3e5 | 7 | #include "Servo.h" |
RobinN7 | 0:3af30bfbc3e5 | 8 | |
RobinN7 | 0:3af30bfbc3e5 | 9 | //Differents objet/variable global |
RobinN7 | 0:3af30bfbc3e5 | 10 | |
AlexandreN7 | 1:49100fa5e278 | 11 | //test de commit |
RobinN7 | 0:3af30bfbc3e5 | 12 | |
RobinN7 | 0:3af30bfbc3e5 | 13 | Serial uart(PTD3, PTD2); |
RobinN7 | 0:3af30bfbc3e5 | 14 | Servo servo(PTD0); |
RobinN7 | 0:3af30bfbc3e5 | 15 | |
RobinN7 | 0:3af30bfbc3e5 | 16 | |
RobinN7 | 0:3af30bfbc3e5 | 17 | int main() { |
RobinN7 | 0:3af30bfbc3e5 | 18 | // Initialisation |
RobinN7 | 0:3af30bfbc3e5 | 19 | |
RobinN7 | 0:3af30bfbc3e5 | 20 | int indexMin=0; |
RobinN7 | 0:3af30bfbc3e5 | 21 | int indexMax=128; |
RobinN7 | 0:3af30bfbc3e5 | 22 | int max_detect=indexMin; |
RobinN7 | 0:3af30bfbc3e5 | 23 | uart.baud(115200); |
RobinN7 | 0:3af30bfbc3e5 | 24 | init_led(); |
RobinN7 | 0:3af30bfbc3e5 | 25 | |
RobinN7 | 0:3af30bfbc3e5 | 26 | // Init UART baudrate |
RobinN7 | 0:3af30bfbc3e5 | 27 | |
RobinN7 | 0:3af30bfbc3e5 | 28 | |
RobinN7 | 0:3af30bfbc3e5 | 29 | // Lancement boucle |
RobinN7 | 0:3af30bfbc3e5 | 30 | while(1){ |
RobinN7 | 0:3af30bfbc3e5 | 31 | |
RobinN7 | 0:3af30bfbc3e5 | 32 | readline(); |
RobinN7 | 0:3af30bfbc3e5 | 33 | |
RobinN7 | 0:3af30bfbc3e5 | 34 | passebas(); |
RobinN7 | 0:3af30bfbc3e5 | 35 | |
RobinN7 | 0:3af30bfbc3e5 | 36 | uart.printf("S"); |
RobinN7 | 0:3af30bfbc3e5 | 37 | for (int indice_pixel=0; indice_pixel<128; indice_pixel++) |
RobinN7 | 0:3af30bfbc3e5 | 38 | { |
RobinN7 | 0:3af30bfbc3e5 | 39 | uart.printf("%d,",pixel[indice_pixel]); |
RobinN7 | 0:3af30bfbc3e5 | 40 | } |
RobinN7 | 0:3af30bfbc3e5 | 41 | uart.printf("E"); |
RobinN7 | 0:3af30bfbc3e5 | 42 | //uart.printf("\n\r"); |
RobinN7 | 0:3af30bfbc3e5 | 43 | |
RobinN7 | 0:3af30bfbc3e5 | 44 | for (int j=indexMin; j<indexMax; j++) |
RobinN7 | 0:3af30bfbc3e5 | 45 | { |
RobinN7 | 0:3af30bfbc3e5 | 46 | if (pixel[j]>pixel[max_detect]) |
RobinN7 | 0:3af30bfbc3e5 | 47 | { |
RobinN7 | 0:3af30bfbc3e5 | 48 | max_detect=j; |
RobinN7 | 0:3af30bfbc3e5 | 49 | } |
RobinN7 | 6:a4e49784b533 | 50 | } |
RobinN7 | 6:a4e49784b533 | 51 | // Réduction de la vitesse moteur si l'angle du servo augmente |
RobinN7 | 6:a4e49784b533 | 52 | if (max_detect>64) |
RobinN7 | 6:a4e49784b533 | 53 | { |
RobinN7 | 6:a4e49784b533 | 54 | consigne_moteur_1=6-(max_detect-64)/20.; |
RobinN7 | 6:a4e49784b533 | 55 | consigne_moteur_2=6-(max_detect-64)/15.; |
RobinN7 | 0:3af30bfbc3e5 | 56 | } |
RobinN7 | 6:a4e49784b533 | 57 | else |
RobinN7 | 6:a4e49784b533 | 58 | { |
RobinN7 | 6:a4e49784b533 | 59 | consigne_moteur_1=6-(64-max_detect)/15.; |
RobinN7 | 6:a4e49784b533 | 60 | consigne_moteur_2=6-(64-max_detect)/20.; |
RobinN7 | 6:a4e49784b533 | 61 | } |
RobinN7 | 6:a4e49784b533 | 62 | servo = 1.4*(double(max_detect)/128.-0.5)+0.5; |
RobinN7 | 0:3af30bfbc3e5 | 63 | |
RobinN7 | 0:3af30bfbc3e5 | 64 | } |
RobinN7 | 0:3af30bfbc3e5 | 65 | } |
RobinN7 | 0:3af30bfbc3e5 | 66 |