Durakovic Adna Pejovic Luka

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 BusOut ledice(dp23, dp24, dp25, dp26, dp27, dp5, dp6, dp28);
00004 
00005 DigitalOut enable(dp14);
00006 DigitalIn t1(dp1);
00007 DigitalIn t2(dp2);
00008 
00009 int main() {
00010     int pritT1 = 0;
00011     int pritT2 = 0;
00012      
00013     int broj = 0, c = 0;
00014     enable = 0;
00015     ledice = broj;
00016     
00017     while(1) {
00018        
00019             for(int i = 0; i < 1000; i++)
00020             { 
00021                 if(t1 == 1) c++;
00022                 if(c>500) break;
00023     
00024             }
00025             if(c > 500){
00026                  broj++;
00027                  pritT1 = 1;
00028                  c = 0;
00029             }
00030             else {
00031                 pritT2 = 0;
00032                 
00033             }
00034             c = 0;
00035         
00036             
00037         //if(pritT2 == 0 && t2 == 1) broj--;
00038         
00039         if(broj < 0) broj = 255;
00040         if(broj > 255) broj = 0;
00041         
00042         ledice =  broj;
00043         
00044        
00045     }
00046 }