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
Fork of APP1_customProtocole by
main.cpp@1:7b43594a95f3, 2016-01-07 (annotated)
- Committer:
- yannolecool
- Date:
- Thu Jan 07 20:43:57 2016 +0000
- Revision:
- 1:7b43594a95f3
- Parent:
- 0:544fa864099a
- Child:
- 2:451888674389
Premi?re version d 'un afficheur avec 2 digits
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| yannolecool | 0:544fa864099a | 1 | #include "mbed.h" |
| yannolecool | 0:544fa864099a | 2 | |
| yannolecool | 1:7b43594a95f3 | 3 | #define CLR_DISPLAY 0x76 |
| yannolecool | 1:7b43594a95f3 | 4 | |
| yannolecool | 1:7b43594a95f3 | 5 | Serial afficheur(p13, p14); |
| yannolecool | 1:7b43594a95f3 | 6 | |
| yannolecool | 1:7b43594a95f3 | 7 | void display2decimal(int number); |
| yannolecool | 0:544fa864099a | 8 | |
| yannolecool | 0:544fa864099a | 9 | int main() { |
| yannolecool | 1:7b43594a95f3 | 10 | int compteur = 0; |
| yannolecool | 0:544fa864099a | 11 | while(1) { |
| yannolecool | 1:7b43594a95f3 | 12 | display2decimal(compteur); |
| yannolecool | 1:7b43594a95f3 | 13 | compteur++; |
| yannolecool | 1:7b43594a95f3 | 14 | wait(0.5); |
| yannolecool | 0:544fa864099a | 15 | } |
| yannolecool | 0:544fa864099a | 16 | } |
| yannolecool | 1:7b43594a95f3 | 17 | |
| yannolecool | 1:7b43594a95f3 | 18 | //Affiche automatique un nombre avec 2 dgits |
| yannolecool | 1:7b43594a95f3 | 19 | //Pour display 12.35 il faut envoyer 1235 |
| yannolecool | 1:7b43594a95f3 | 20 | void display2decimal(int number) |
| yannolecool | 1:7b43594a95f3 | 21 | { |
| yannolecool | 1:7b43594a95f3 | 22 | int digit1 = number / 1000; |
| yannolecool | 1:7b43594a95f3 | 23 | int rest = number - digit1 * 1000; |
| yannolecool | 1:7b43594a95f3 | 24 | int digit2 = rest / 100; |
| yannolecool | 1:7b43594a95f3 | 25 | rest -= digit2 * 100; |
| yannolecool | 1:7b43594a95f3 | 26 | int digit3 = rest / 10; |
| yannolecool | 1:7b43594a95f3 | 27 | rest -= digit3 * 10; |
| yannolecool | 1:7b43594a95f3 | 28 | int digit4 = rest; |
| yannolecool | 1:7b43594a95f3 | 29 | |
| yannolecool | 1:7b43594a95f3 | 30 | //Put the cursor at the first digit |
| yannolecool | 1:7b43594a95f3 | 31 | afficheur.putc(0x79); |
| yannolecool | 1:7b43594a95f3 | 32 | afficheur.putc(0x00); |
| yannolecool | 1:7b43594a95f3 | 33 | |
| yannolecool | 1:7b43594a95f3 | 34 | //Write 2 first digits |
| yannolecool | 1:7b43594a95f3 | 35 | afficheur.putc(digit1); |
| yannolecool | 1:7b43594a95f3 | 36 | afficheur.putc(digit2); |
| yannolecool | 1:7b43594a95f3 | 37 | |
| yannolecool | 1:7b43594a95f3 | 38 | //Add the dot after two digit |
| yannolecool | 1:7b43594a95f3 | 39 | afficheur.putc(0x77); |
| yannolecool | 1:7b43594a95f3 | 40 | afficheur.putc(0b00000010); |
| yannolecool | 1:7b43594a95f3 | 41 | |
| yannolecool | 1:7b43594a95f3 | 42 | //Write the last two digits |
| yannolecool | 1:7b43594a95f3 | 43 | afficheur.putc(digit3); |
| yannolecool | 1:7b43594a95f3 | 44 | afficheur.putc(digit4); |
| yannolecool | 1:7b43594a95f3 | 45 | } |
