Adijata Vukas / Mbed 2 deprecated LV2_Grupa2_Tim8_Zadatak2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 
00004 #define dp23 P0_0
00005 DigitalOut enable(dp14);
00006 
00007 
00008 BusOut cifre(dp26,dp27,dp5,dp6,dp28,dp4,dp18,dp17), brReda(dp23,dp24,dp25);
00009 DigitalIn taster1(dp1),taster2(dp2);
00010 
00011 
00012 int cifreBroja[10] = {64,121,36,48,25,18,2,120,0,16};
00013 
00014 int brojac = 0;
00015 
00016 void smanji() { brojac--; if(brojac < 0) brojac = 0; }
00017 void povecaj() { brojac++; if (brojac > 999) brojac = 999; }
00018 
00019 int main() {
00020     enable = 0;
00021     bool jednoPritisnuto = false;
00022     
00023     while(1) {
00024         while(taster1)
00025         {
00026             if(jednoPritisnuto == false)
00027             {
00028                 povecaj();
00029                 jednoPritisnuto = true;
00030             }
00031         }
00032         while(taster2)
00033         {
00034             if(jednoPritisnuto == false)
00035             {            
00036                 smanji();
00037                 jednoPritisnuto = true;
00038             }
00039         }
00040         jednoPritisnuto = false;
00041 
00042         
00043         int cifra1 = brojac % 10, cifra2 = (brojac/10) % 10, cifra3 = (brojac/100) %10;
00044         
00045         brReda = 6;
00046         cifre =  cifreBroja[cifra3] - 128;
00047          wait(0.005);        
00048 
00049         brReda = 5;
00050         cifre = cifreBroja[cifra2] - 128;  
00051         wait(0.005);        
00052 
00053         
00054         brReda = 3;
00055         cifre = cifreBroja[cifra1] - 128;
00056         wait(0.005);        
00057     }
00058 }