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.
Dependencies: TextLCD mbed PinDetect
Diff: main.cpp
- Revision:
- 7:ac67f44120a5
- Parent:
- 6:902bec57d9ae
- Child:
- 8:4044ae40bbc1
diff -r 902bec57d9ae -r ac67f44120a5 main.cpp
--- a/main.cpp Mon Nov 11 11:45:55 2013 +0000
+++ b/main.cpp Mon Nov 11 13:14:10 2013 +0000
@@ -1,5 +1,6 @@
#include "mbed.h"
#include "Motor.h"
+#include "TextLCD.h"
#define sensorStartTreshold 0.05
#define sensorStopTreshold 0.01
@@ -9,10 +10,16 @@
#define calibrateFactorSenzC 1.06
#define calibrateFactorSenzD 0.9
-#define serialOutputEnable true
+#define lcdOutputEnable true
+#define serialOutputEnable false
#define serialOutputBaudrate 115200
Serial pc(USBTX, USBRX);
+TextLCD lcd(p15, p16, p5, p6, p7, p8); // rs, e, d4-d7
+
+DigitalOut ledBoot(LED1);
+DigitalOut ledAz(LED3);
+DigitalOut ledEl(LED4);
AnalogIn ainSensA(p17);
AnalogIn ainSensB(p18);
@@ -56,27 +63,25 @@
pc.printf("az:%6.3f el:%6.3f \n", valAzimut, valElevacija);
}
+
+ if(lcdOutputEnable) {
+ lcd.cls();
+ lcd.printf("a:%6.3f \n", valAzimut);
+ }
+
}
int main() {
+ ledBoot = 1;
pc.baud(serialOutputBaudrate);
-
Motor *motorAz = new Motor(p25, p26, p24);
Motor *motorEl = new Motor(p22, p21, p23);
+ wait_ms(500);
+ ledBoot = 0;
while(1) {
-
- (*motorEl).movePositive();
- (*motorAz).movePositive();
- wait(5);
- (*motorAz).moveNegative();
- (*motorEl).moveNegative();
- wait(3);
- continue;
-
-
-
+
readValuesForAveraging();
// ----- azimut -----
@@ -86,10 +91,12 @@
(*motorAz).movePositive();
else
(*motorAz).moveNegative();
+ ledAz = 1;
}
if(abs(valAzimut) < sensorStopTreshold) {
(*motorAz).stop();
+ ledAz = 0;
}
// ----- elevacija -----
@@ -99,15 +106,17 @@
(*motorEl).movePositive();
else
(*motorEl).moveNegative();
+ ledEl = 1;
}
if(abs(valElevacija) < sensorStopTreshold) {
(*motorEl).stop();
+ ledEl = 0;
}
// ----- pauza ------
- wait_ms(100);
+ wait_ms(200);
}
}
