motor i senzor

Dependencies:   TextLCD mbed PinDetect

Files at this revision

API Documentation at this revision

Comitter:
cvitas
Date:
Fri Jan 17 14:40:31 2014 +0000
Parent:
11:f243d8ed556d
Commit message:
danchi 1

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r f243d8ed556d -r 8cb20afa1694 main.cpp
--- a/main.cpp	Wed Dec 11 14:54:25 2013 +0000
+++ b/main.cpp	Fri Jan 17 14:40:31 2014 +0000
@@ -16,7 +16,7 @@
 #define serialOutputBaudrate    9600
 
 Serial pc(USBTX, USBRX);
-TextLCD lcd(p13, p14, p5, p6, p7, p8); // rs, e, d4-d7
+TextLCD lcd(p5, p6, p7, p8, p9, p10); // rs, e, d4-d7
 
 Ticker Prikaz;
 
@@ -24,13 +24,19 @@
 DigitalOut ledAz(LED3); 
 DigitalOut ledEl(LED4);
 
+DigitalOut R1(p26);
+DigitalOut R2(p25);
+DigitalOut R3(p24);
+DigitalOut R4(p23);
+
+
 AnalogIn ainSensA(p16);
 AnalogIn ainSensB(p17);
 AnalogIn ainSensC(p18);
 AnalogIn ainSensD(p19);
 
-PinDetect pb_azimut(p11);
-PinDetect pb_elevacija(p12);
+PinDetect pb_azimut(p30);
+PinDetect pb_elevacija(p29);
 
 float valAzimut = 0;
 float valElevacija = 0;
@@ -107,6 +113,8 @@
 int main() {   
 
     ledBoot = 1;
+    Motor *motorEl = new Motor(p23, p24, p22);
+    /*
      Prikaz.attach(&od_prikaza, 0.1);
     
     // Setup Interrupt callback function for a pb hit
@@ -117,83 +125,43 @@
     pb_azimut.setSampleFrequency();
     pc.baud(serialOutputBaudrate);
     
-    Motor *motorAz = new Motor(p28, p27, p26); // relej, relej, pwm
-    Motor *motorEl = new Motor(p24, p23, p25);
-    if(lcdOutputEnable) {
+    Motor *motorAz = new Motor(p25, p26, p21); // relej, relej, pwm
+     
+    if(lcdOutputEnable) {*/
+    
+    while(1){
+     ledBoot = 1;   
         lcd.cls();
         lcd.printf("Suncokre\n");    
         lcd.printf("t  TVZ  \n");    
-    }
-    wait_ms(5000);
-    ledBoot = 0;
-
-    while(1) {
-    
-    data2 = GetKeyInput();  // call function to get 1st key press
-    switch (data2) {
-    case 0: 
-        (*motorAz).stop();
-        (*motorEl).stop();
-        break;
-    case 1: 
-        (*motorAz).movePositive();
-        break;
-    case 2:
-        (*motorAz).moveNegative();
-        break;
-    case 3:
-        (*motorEl).movePositive();
-        break;
-    case 4:
-        (*motorEl).moveNegative();
-        break;
-    default:
-        (*motorAz).stop();
-        (*motorEl).stop();
-        break;
-     }             
-    
-    /*
-// ---- citanje senzora ------------    
     
-        readValuesForAveraging();
-        
-// ----- azimut -----
-        
-        if(abs(valAzimut) > sensorStartTreshold) {
-            if(valAzimut > 0) 
-                (*motorAz).movePositive();
-            else
-                (*motorAz).moveNegative();
-            ledAz = 1;
-        }
-        
-        if(abs(valAzimut) < sensorStopTreshold) {
-            (*motorAz).stop();
-            ledAz = 0;
-        }
-        
-// ----- elevacija -----
-
-        if(abs(valElevacija) > sensorStartTreshold) {
-            if(valElevacija > 0) 
-                (*motorEl).movePositive();
-            else
-                (*motorEl).moveNegative();
-            ledEl = 1;
-        }
-        
-        if(abs(valElevacija) < sensorStopTreshold) {
-            (*motorEl).stop();
-            ledEl = 0;
-        }
-        */
-// ----- pauza ------
-
-        
-        //wait_ms(200);  
-        
-    }
+    wait_ms(200);
+    ledBoot = 0;
+    wait_ms(200);
+     (*motorEl).stop();
+     /*
+    R1 = 1;
+    R2 = 0;R3=0;R4=0;
+    wait_ms(1000);
+    R2 = 1;
+    R1 = 0;R3=0;R4=0;
+    wait_ms(1000);
+    R3 = 1;
+    R2 = 0;R1=0;R4=0;
+    wait_ms(1000);
+    R4 = 1;
+    R2 = 0;R3=0;R1=0;*/
+    
+    wait_ms(600);
+    (*motorEl).movePositive();
+    wait_ms(1000);
+    (*motorEl).stop();
+    (*motorEl).moveNegative();
+    wait_ms(1000);
+    
+    
+}
+    
 }