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: LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI
ClickClickClouk/codeurRotatifRelatif.cpp
- Committer:
- ascheriit
- Date:
- 2019-04-29
- Revision:
- 19:09ad3ca689f3
- Parent:
- 18:1864979c9b3c
- Child:
- 20:f3e8319b7899
File content as of revision 19:09ad3ca689f3:
#include "codeurRotatifRelatif.h" #include <mbed.h> int CdRelatif(void){ DigitalIn pinClick(PG_2); DigitalIn pinRot1(PG_3); DigitalIn pinRot2(PG_9); int actA; //def des variables int actB; int actOldA=0; int actOldB=0; while(!pinClick.read()){ //on attent un résultat actB=!pinRot1.read(); //On lit ce qui se passe aux bornes du codeur actA=!pinRot2.read(); if(actA && actB){ //un truc se passe int r = 1 - 2 * actOldA; //dans un sens on a 1, dans l'autre on a -1 return r; } actOldA=actA || actOldA; actOldB=actB || actOldB; } return 0; } void cRR_test(void){ LCD_DISCO_F429ZI lcdTemp; lcdTemp.Clear(LCD_COLOR_BLUE); /*for(ever){ lcdTemp.Clear(LCD_COLOR_BLUE); int val=CdRelatif(); BS_displayChiffre(50,50,val,4,LCD_COLOR_WHITE); wait(1); }*/ int a=0; for(ever){ lcdTemp.Clear(LCD_COLOR_BLUE); int val=CdRelatif(); if(val){ a=a+val; }else{ BS_displayChiffre100Clean(50,50,a,4,LCD_COLOR_WHITE,LCD_COLOR_BLUE); BS_displayChiffreClean(150,150,val,4,LCD_COLOR_WHITE,LCD_COLOR_BLUE); wait(1); } } }