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.
Revision 0:a4f3aa903302, committed 2014-05-09
- Comitter:
- gcarmonar
- Date:
- Fri May 09 15:31:05 2014 +0000
- Commit message:
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri May 09 15:31:05 2014 +0000
@@ -0,0 +1,51 @@
+/*
+ INSTRUCCIONES:
+ Suponga que tiene 3 botones con resistencias de pull-up (A, B, C)
+ y un display de 7 segmentos de cátodo común. Realice un programa
+ que convierta de número binario a display de 7 segmentos.
+*/
+
+#include "mbed.h"
+
+DigitalIn A(D2);
+DigitalIn B(D3);
+DigitalIn C(D4);
+BusOut display(D5, D6, D7, D8, D9, D10, D11);
+
+void bcd_to_7segment(int number);
+
+bool button_A, button_B, button_C;
+int number;
+
+int main() {
+ A.mode(PullUp);
+ B.mode(PullUp);
+ C.mode(PullUp);
+ while(1){
+ button_A = !A;
+ button_B = !B;
+ button_C = !C;
+ number = A + B*2 + C*4; //tambien se puede number = A | B << 1 | C << 2;
+ bcd_to_7segment(number);
+ }
+}
+
+void bcd_to_7segment(int number){
+ switch (number){
+ case 0:
+ display = 63; break;
+ case 1:
+ display = 6; break;
+ case 2:
+ display = 91; break;
+ case 3:
+ display = 79; break;
+ case 4:
+ display = 102; break;
+ case 5:
+ display = 109; break;
+ case 6:
+ display = 125; break;
+ case 7:
+ display = 7; break;
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 09 15:31:05 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/8e73be2a2ac1 \ No newline at end of file