Mirhat Babić Granulo Eldar
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 using namespace std; 00004 00005 BusOut segments(dp26, dp27, dp5, dp6, dp28, dp1, dp2); 00006 BusOut digit(dp23, dp24, dp25); 00007 DigitalOut point(dp4); 00008 00009 Timer count; 00010 00011 int codes[10] = {0x40,0x79,0x24,0x30,0x19,0x12,0x02,0x078,0x0,0x10}; 00012 00013 00014 00015 void display(float time) { 00016 int numbers[3] = { (int)(time / 10.) % 10, (int)(time) % 10, 00017 (int)(time * 10.) % 10 }; 00018 00019 00020 digit = 3; 00021 segments = codes[ numbers[2]]; 00022 wait_ms(2); 00023 00024 digit = 7; 00025 00026 digit = 5; 00027 segments = codes[ numbers[1]]; 00028 point = 0; 00029 wait_ms(2); 00030 00031 digit = 7; 00032 00033 digit = 6; 00034 segments = codes[ numbers[0]]; 00035 point = 1; 00036 00037 wait_ms(2); 00038 00039 digit = 7; 00040 00041 digit = 0; 00042 segments = 7; 00043 point = 1; 00044 } 00045 00046 int main() { 00047 00048 wait(2.); 00049 count.start(); 00050 00051 00052 while(true) { 00053 if(count.read() > 12.3) display(12.3); 00054 else display(count.read()); 00055 00056 } 00057 00058 00059 }
Generated on Tue Aug 23 2022 10:36:07 by
1.7.2