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:
- 31:adfe162a58a4
- Parent:
- 30:0027d243841b
diff -r 0027d243841b -r adfe162a58a4 main.cpp
--- a/main.cpp Wed Sep 09 13:10:07 2020 +0000
+++ b/main.cpp Wed Sep 09 14:43:03 2020 +0000
@@ -3,68 +3,20 @@
DigitalOut LEDB(LED3);
DigitalOut LEDR(LED1);
DigitalOut LEDV(LED2);
-DigitalIn BP1(D3);
-DigitalIn BP2(PTC6);
-DigitalIn BP3(PTA4);
-
+BusIn nibble(D3,PTA4,PTC6);
int main() {
while(1) { // c'est la boucle
- if (!BP1&&BP2&&BP3) // si le BP2 est appuyé
- {
- LEDB=1;
- LEDR=1;
- LEDV=1;
- }
-
- if (!BP1&&!BP2&&BP3) // si le BP2 est appuyé
- {
- LEDB=0;
- LEDR=1;
- LEDV=1;
- }
-
- if (!BP1&&BP2&&!BP3) // si le BP2 est appuyé
- {
- LEDB=1;
- LEDR=1;
- LEDV=0;
- }
-
- if (!BP1&&!BP2&&!BP3) // si le BP2 est appuyé
- {
- LEDB=1;
- LEDR=0;
- LEDV=1;
- }
-
- if (BP1&&BP2&&BP3) // si le BP2 est appuyé
- {
- LEDB=0;
- LEDR=1;
- LEDV=0;
- }
-
- if (BP1&&!BP2&&BP3) // si le BP2 est appuyé
- {
- LEDB=0;
- LEDR=0;
- LEDV=1;
- }
-
- if (BP1&&BP2&&!BP3) // si le BP2 est appuyé
- {
- LEDB=1;
- LEDR=0;
- LEDV=0;
- }
-
- if (BP1&&!BP2&&!BP3) // si le BP2 est appuyé
- {
- LEDB=0;
- LEDR=0;
- LEDV=0;
- }
+ switch(nibble) {
+ case 0b110: LEDB=1;LEDR=1;LEDV=1;; break; // p5 and p6 are 1
+ case 0b010: LEDB=0;LEDR=1;LEDV=1;; break;
+ case 0b100: LEDB=1;LEDR=1;LEDV=0;; break;
+ case 0b000: LEDB=1;LEDR=0;LEDV=1;; break;
+ case 0b111: LEDB=0;LEDR=1;LEDV=0;; break;
+ case 0b011: LEDB=0;LEDR=0;LEDV=1;; break;
+ case 0b101: LEDB=1;LEDR=0;LEDV=0;; break;
+ case 0b001: LEDB=0;LEDR=0;LEDV=0;; break;
+ }
} // fin boucle infinie
} // fin programme