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
Revision 0:d54c76ac1184, committed 2018-03-17
- Comitter:
- shimogamo
- Date:
- Sat Mar 17 04:29:17 2018 +0000
- Child:
- 1:3dfd9c4c2520
- Commit message:
- create repository
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 Sat Mar 17 04:29:17 2018 +0000
@@ -0,0 +1,79 @@
+#include "mbed.h"
+
+DigitalOut dig_1(p15);
+DigitalOut dig_2(p27);
+DigitalOut dig_3(p28);
+DigitalOut dig_4(p21);
+
+DigitalOut seg_a(p30);
+DigitalOut seg_b(p26);
+DigitalOut seg_c(p13);
+DigitalOut seg_d(p11);
+DigitalOut seg_e(p10);
+DigitalOut seg_f(p29);
+DigitalOut seg_g(p14);
+DigitalOut seg_dp(p12);
+
+
+#define N_0 (0x03)
+#define N_1 (0x9f)
+#define N_2 (0x25)
+#define N_3 (0x0d)
+#define N_4 (0x99)
+#define N_5 (0x49)
+#define N_6 (0x41)
+#define N_7 (0x1b)
+#define N_8 (0x01)
+#define N_9 (0x09)
+const char segData[10] = {N_0, N_1, N_2, N_3, N_4, N_5, N_6, N_7, N_8, N_9,};
+
+void segDataSet(unsigned char num){
+ unsigned char work;
+
+ work = segData[num];
+
+ seg_a = (work & 0x80) ? 0 : 1;
+ seg_b = (work & 0x40) ? 0 : 1;
+ seg_c = (work & 0x20) ? 0 : 1;
+ seg_d = (work & 0x10) ? 0 : 1;
+ seg_e = (work & 0x08) ? 0 : 1;
+ seg_f = (work & 0x04) ? 0 : 1;
+ seg_g = (work & 0x02) ? 0 : 1;
+ seg_dp = (work & 0x01) ? 0 : 1;
+}
+
+
+int main(){
+ unsigned int cnt = 0;
+ unsigned char sel = 1;
+
+ while(1){
+ for(int i=0; i<1000; i++){
+ dig_1 = 1;
+ dig_2 = 1;
+ dig_3 = 1;
+ dig_4 = 1;
+ switch(sel){
+ case 1: dig_1 = 0;
+ segDataSet((char)(cnt % 10));
+ break;
+ case 2: dig_2 = 0;
+ segDataSet((char)(cnt / 10) % 10);
+ seg_dp = 1;
+ break;
+ case 3: dig_3 = 0;
+ segDataSet((char)(cnt / 100) % 10);
+ break;
+ case 4: dig_4 = 0;
+ segDataSet((char)(cnt / 1000));
+ break;
+ }
+ sel++;
+ if(sel==5) sel=1;
+ wait_ms(1);
+ }
+ //cnt++; if(cnt==10000)cnt=0;
+ cnt = 0 + (int)(rand()*(9999-0+1.0)/(1.0+RAND_MAX));
+ //wait_ms(10);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Mar 17 04:29:17 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/25aea2a3f4e3 \ No newline at end of file