tim003 tim003
/
LV2_Grupa1_Tim003_Zadatak3
Irma Jakić Tarik Demirović
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 00003 DigitalIn Ulaz1(dp16); 00004 DigitalIn Ulaz2(dp15); 00005 DigitalIn Ulaz3(dp17); 00006 DigitalIn Ulaz4(dp18); 00007 DigitalOut Izlaz1(dp9); 00008 DigitalOut Izlaz2(dp10); 00009 DigitalOut Izlaz3(dp11); 00010 DigitalOut Izlaz4(dp13); 00011 00012 BusOut leds(dp23, dp24, dp25, dp26, dp27, dp5, dp6, dp28); 00013 DigitalOut enable(dp14); 00014 00015 00016 int kojiJePritisnut() 00017 { 00018 Izlaz1 = 1; 00019 Izlaz2 = 0; 00020 Izlaz3 = 0; 00021 Izlaz4 = 0; 00022 if(Ulaz1){ 00023 return 1; 00024 } 00025 if(Ulaz2){ 00026 return 4; 00027 } 00028 if(Ulaz3){ 00029 return 7; 00030 } 00031 if(Ulaz4){ 00032 return 10; 00033 } 00034 00035 Izlaz1 = 0; 00036 Izlaz2 = 1; 00037 Izlaz3 = 0; 00038 Izlaz4 = 0; 00039 if(Ulaz1){ 00040 return 2; 00041 } 00042 if(Ulaz2){ 00043 return 5; 00044 } 00045 if(Ulaz3){ 00046 return 8; 00047 } 00048 if(Ulaz4){ 00049 return 0; 00050 } 00051 00052 Izlaz1 = 0; 00053 Izlaz2 = 0; 00054 Izlaz3 = 1; 00055 Izlaz4 = 0; 00056 if(Ulaz1){ 00057 return 3; 00058 } 00059 if(Ulaz2){ 00060 return 6; 00061 } 00062 if(Ulaz3){ 00063 return 9; 00064 } 00065 if(Ulaz4){ 00066 return 11; 00067 } 00068 00069 Izlaz1 = 0; 00070 Izlaz2 = 0; 00071 Izlaz3 = 0; 00072 Izlaz4 = 1; 00073 if(Ulaz1){ 00074 return 12; 00075 } 00076 if(Ulaz2){ 00077 return 13; 00078 } 00079 if(Ulaz3){ 00080 return 14; 00081 } 00082 if(Ulaz4){ 00083 return 15; 00084 } 00085 00086 return 16; 00087 } 00088 00089 00090 int main() { 00091 enable = 0; 00092 leds = 255; 00093 int broj; 00094 while(1) 00095 { 00096 broj = kojiJePritisnut(); 00097 if(broj == 1) 00098 { 00099 leds = 254; 00100 } 00101 00102 if(broj == 2) 00103 { 00104 leds = 253; 00105 } 00106 00107 if(broj == 3) 00108 { 00109 leds = 251; 00110 } 00111 00112 if(broj == 4) 00113 { 00114 leds = 247; 00115 } 00116 00117 if(broj == 5) 00118 { 00119 leds = 239; 00120 } 00121 00122 if(broj == 6) 00123 { 00124 leds = 223; 00125 } 00126 00127 if(broj == 7) 00128 { 00129 leds = 191; 00130 } 00131 00132 if(broj == 8) 00133 { 00134 leds = 127; 00135 } 00136 } 00137 }
Generated on Thu Aug 25 2022 02:36:05 by 1.7.2