Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 /* 00002 * Mihailo Radivojevic 2018/0436 00003 */ 00004 00005 /* 00006 * Uvoz biblioteka 00007 */ 00008 #include "mbed.h" 00009 00010 /* 00011 * Definisanje makroa 00012 */ 00013 00014 #define VOLTAGE_SCALE 3.3f 00015 #define STARTHZ 200 00016 #define STEPHZ 200 00017 #define STEPV 0.01f 00018 #define REC 1 00019 #define US 1000000 00020 #define PAUSEMS 50 00021 #define PERCENT 100 00022 #define SEL_OFF 1 00023 #define SEL_ON 0 00024 #define PAUSE 50 //ms 00025 #define PAUSE2 10 //ms 00026 00027 /* 00028 * Globalne promenljive 00029 */ 00030 AnalogIn pot1(PA_0); 00031 AnalogIn pot2(PA_1); 00032 PwmOut zzz(PA_11); 00033 InterruptIn sw1(PC_9); 00034 BusOut display(PA_10, PA_9, PA_8, PB_10, PB_5, PB_4, PB_3, D0); 00035 DigitalOut sel2(PC_7); 00036 DigitalOut sel1(PB_6); 00037 int i; 00038 /* 00039 * Definisanje funkcija 00040 */ 00041 void ISR_button (void); 00042 /* 00043 * Glavna funkcija 00044 */ 00045 int main() 00046 { 00047 //Lokalne Promenljive 00048 static int brojevi[] {0xC0, 0xF9, 0xA4, 0xB0, 0x99, 0x92, 0x82, 0xF8, 0x80, 0x90}; 00049 static double periods, a; 00050 static int p, s; 00051 00052 //Funkcije koje se izvrsavaju samo jednom 00053 sw1.fall(&ISR_button); 00054 //Beskonacna petlja 00055 while (true) { 00056 a = pot2; 00057 periods = (REC / (STARTHZ + a * STEPHZ / STEPV)) * US; 00058 zzz.period_us(periods); 00059 zzz = pot1; 00060 00061 if (!sw1) 00062 { 00063 i = pot1*PERCENT; 00064 } 00065 if (i<10){ 00066 sel2.write(SEL_ON); 00067 display.write(brojevi[i]); 00068 wait_ms(PAUSE); 00069 } 00070 else 00071 { 00072 p = i/10; 00073 s = i%10; 00074 sel1.write(SEL_ON); 00075 display.write(brojevi[p]); 00076 wait_ms(PAUSE2); 00077 sel1.write(SEL_OFF); 00078 sel2.write(SEL_ON); 00079 display.write(brojevi[s]); 00080 wait_ms(PAUSE2); 00081 sel2.write(SEL_OFF); 00082 } 00083 00084 00085 } 00086 } 00087 00088 /* 00089 * Definicija funkcija: 00090 */ 00091 void ISR_button (){ 00092 i = pot1*PERCENT; 00093 00094 } 00095 00096
Generated on Fri Jun 7 2024 14:02:47 by
1.7.2