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 #include "mbed.h" 00002 #define dp23 P0_0 00003 00004 Serial pc(USBTX, USBRX); // tx, rx 00005 00006 AnalogIn VRx(dp11); 00007 AnalogIn VRy(dp10); 00008 00009 DigitalIn SW(dp9); 00010 Timer timer; 00011 00012 int smijer = 0; // 1 - lijevo, 3 - gore, 2 - desno, 4 - dole, 5 - centar 00013 00014 void usmjerenje(int noviSmijer) 00015 { 00016 if(noviSmijer != smijer) 00017 { 00018 smijer = noviSmijer; 00019 char text[300]; 00020 00021 if(smijer == 1) 00022 { 00023 sprintf(text, "lijevo\n"); 00024 pc.printf(text); 00025 }else if(smijer == 2) 00026 { 00027 sprintf(text, "desno\n"); 00028 pc.printf(text); 00029 }else if(smijer == 3) 00030 { 00031 sprintf(text, "gore\n"); 00032 pc.printf(text); 00033 }else if(smijer == 4) 00034 { 00035 sprintf(text, "dole\n"); 00036 pc.printf(text); 00037 }else if(smijer == 5) 00038 { 00039 sprintf(text, "centar\n"); 00040 pc.printf(text); 00041 } 00042 } 00043 00044 } 00045 00046 int main() { 00047 SW.mode(PullUp); 00048 timer.start(); 00049 while (1) 00050 { 00051 if(VRx < 1.0/3.0) 00052 usmjerenje(1); // lijevo 00053 else if(VRx < 2.0/3.0) 00054 usmjerenje(5); // centar 00055 else 00056 usmjerenje(2); // desno 00057 00058 if(VRy < 1.0/3.0) 00059 usmjerenje(3); // gore 00060 else if(VRy < 2.0/3.0) 00061 usmjerenje(5); // centar 00062 else 00063 usmjerenje(4); // dole 00064 wait(1); 00065 } 00066 }
Generated on Wed Jul 20 2022 05:58:30 by
1.7.2