Fahrudin Brbutovic Adnan Mehanovic
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 using namespace std; 00004 00005 BusOut segments(dp2, dp1, dp28, dp6, dp5, dp27, dp26); 00006 BusOut digit(dp23, dp24, dp25); 00007 DigitalOut decimal_point(dp4); 00008 AnalogIn percentage(dp9); 00009 00010 int predefined_segments[10] = {0x01, 0x4f, 0x12, 0x06, 0x4c, 0x24, 0x20, 0x0f, 0x00, 0x04}; 00011 00012 void display(float pct) 00013 { 00014 int timer_digits[3] = {(int)(pct / 100) % 10, (int)(pct / 10) % 10, (int)(pct) % 10}; 00015 for(int i = 1; i <= 4; i = i * 2) { 00016 segments = predefined_segments[timer_digits[i / 2]]; 00017 digit = ~i; 00018 wait_ms(1); 00019 } 00020 } 00021 00022 int main() 00023 { 00024 decimal_point = 1; 00025 while(1) { 00026 double parametar = (1 - ((percentage * 3.3 - 0.3) / 1.5)) * 100; 00027 display(parametar); 00028 } 00029 }
Generated on Sun Sep 25 2022 06:13:55 by
1.7.2