Porča Sumeja Pejović 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 
00004 //Novo za LV4
00005 AnalogIn ulaz(dp9);
00006 //end
00007 //LV5
00008 PwmOut izlaz(dp24);
00009 
00010 BusOut ledice(dp23, dp25, dp26, dp27, dp5, dp6, dp28);
00011 DigitalOut enable(dp14);
00012 //end
00013  
00014 int main() {
00015     float f;
00016     enable = 0;
00017     ledice = 0;
00018     
00019     wait(0.05);
00020     izlaz.period_us(5);
00021     
00022     int counter = 0;
00023     float pot, suma;
00024     float x2(0.46/3.3), x1(2.2/3.3);
00025     float k = -1*(10/(x2 - x1));
00026     wait(0.05);
00027     
00028     pot = ulaz;
00029     while(1){
00030             if(counter == 50){
00031                 pot = suma/50.f;
00032                 counter = 0;
00033                 suma = 0;
00034             }
00035             izlaz = (pot - 0.4) * k;
00036             suma += ulaz;
00037             counter++;
00038     }
00039  
00040 }