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 /* Program Example 6.1: seven-segment display counter 00002 */ 00003 #include "mbed.h" 00004 00005 BusOut Seg1(p5,p6,p7,p8,p9,p10,p11,p12); // A,B,C,D,E,F,G,DP 00006 char SegConvert(char SegValue); // function prototype 00007 char A=0; // declare variables A and B 00008 char B; 00009 00010 int main() { // main program 00011 while (1) { // infinite loop 00012 B=SegConvert(A); // Call function to return B 00013 Seg1=B; // Output B 00014 A++; // increment A 00015 if (A>0x09){ // if A > 9 reset to zero 00016 A=0; 00017 } 00018 wait(0.5); // delay 500 milliseconds 00019 } 00020 } 00021 00022 char SegConvert(char SegValue) { // function 'SegConvert' 00023 char SegByte=0x00; 00024 switch (SegValue) { //DP G F E D C B A 00025 case 0 : SegByte = 0x3F;break; // 0 0 1 1 1 1 1 1 binary 00026 case 1 : SegByte = 0x06;break; // 0 0 0 0 0 1 1 0 binary 00027 case 2 : SegByte = 0x5B;break; // 0 1 0 1 1 0 1 1 binary 00028 case 3 : SegByte = 0x4F;break; // 0 1 0 0 1 1 1 1 binary 00029 case 4 : SegByte = 0x66;break; // 0 1 1 0 0 1 1 0 binary 00030 case 5 : SegByte = 0x6D;break; // 0 1 1 0 1 1 0 1 binary 00031 case 6 : SegByte = 0x7D;break; // 0 1 1 1 1 1 0 1 binary 00032 case 7 : SegByte = 0x07;break; // 0 0 0 0 0 1 1 1 binary 00033 case 8 : SegByte = 0x7F;break; // 0 1 1 1 1 1 1 1 binary 00034 case 9 : SegByte = 0x6F;break; // 0 1 1 0 1 1 1 1 binary 00035 } 00036 return SegByte; 00037 } 00038
Generated on Fri Jul 29 2022 06:21:35 by
1.7.2