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.
main.cpp
00001 #include "mbed.h" 00002 00003 DigitalOut datapin(D8); 00004 DigitalOut latchpin(D9); 00005 DigitalOut clockpin(D10); 00006 DigitalOut xx(D11); 00007 DigitalOut zz(D12); 00008 DigitalOut yy(D13); 00009 00010 const int state[10][8]= { 00011 { 0, 1, 1, 1, 1, 1, 1}, // 0 00012 { 0, 0, 0, 0, 1, 1, 0}, // 1 00013 { 1, 0, 1, 1, 0, 1, 1}, // 2 00014 { 1, 0, 0, 1, 1, 1, 1}, // 3 00015 { 1, 1, 0, 0, 1, 1, 0}, // 4 00016 { 1, 1, 0, 1, 1, 0, 1}, // 5 00017 { 1, 1, 1, 1, 1, 0, 0}, // 6 00018 { 0, 0, 0, 0, 1, 1, 1}, // 7 00019 { 1, 1, 1, 1, 1, 1, 1}, // 8 00020 { 1, 1, 0, 0, 1, 1, 1} // 9 00021 }; 00022 void seg1(int num) 00023 { 00024 xx=1; 00025 zz=1; 00026 yy=1; 00027 latchpin=0; 00028 for(int i=0;i<=7;i++) 00029 { 00030 datapin=state[num][i]; 00031 clockpin=1; 00032 clockpin=0; 00033 } 00034 latchpin=1; 00035 zz=0; 00036 } 00037 void seg2(int num) 00038 { 00039 xx=1; 00040 zz=1; 00041 yy=1; 00042 latchpin=0; 00043 for(int i=0;i<=7;i++) 00044 { 00045 datapin=state[num][i]; 00046 clockpin=1; 00047 clockpin=0; 00048 } 00049 latchpin=1; 00050 xx=0; 00051 } 00052 void seg3(int num) 00053 { 00054 xx=1; 00055 zz=1; 00056 yy=1; 00057 latchpin=0; 00058 for(int i=0;i<=7;i++) 00059 { 00060 datapin=state[num][i]; 00061 clockpin=1; 00062 clockpin=0; 00063 } 00064 latchpin=1; 00065 yy=0; 00066 } 00067 int main() 00068 { 00069 int round=0,round2=0,round3=0,r=0; 00070 while(1) 00071 { 00072 seg1(round); 00073 r++; 00074 if (r>=1) 00075 { 00076 round++; 00077 r=0; 00078 } 00079 wait_ms(1); 00080 seg2(round2); 00081 wait_ms(1); 00082 seg3(round3); 00083 wait_ms(1); 00084 if(round == 10) 00085 { 00086 round=0;round2++; 00087 if(round2 == 10) 00088 { 00089 round2=0;round3++; 00090 if(round3 == 10) 00091 { 00092 round3=0; 00093 } 00094 } 00095 } 00096 } 00097 }
Generated on Sun Sep 11 2022 07:56:46 by
1.7.2