Czosnekengine/UART

Dependencies:   mbed

Fork of Czosnekengine by Dominik Święch

Files at this revision

API Documentation at this revision

Comitter:
yruiewyrui3
Date:
Thu May 19 06:37:57 2016 +0000
Parent:
0:a0c8b50a7292
Commit message:
uart

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed May 18 12:08:19 2016 +0000
+++ b/main.cpp	Thu May 19 06:37:57 2016 +0000
@@ -1,36 +1,46 @@
 #include "Engine.h"
+#include <string>
 
-Serial pc(SERIAL_TX, SERIAL_RX);
-int liczba =0;
+std::string s;
+//int liczba =0;
 int main() {
     //inicjalizacja silnikow - piny dzialaja:
     Engine eng_left = Engine(PB_13, PB_4, PB_10);
     Engine eng_right = Engine(PB_14, PB_5, PB_3);
-    
+    Serial pc(PA_2, PA_3);
     
     while(true) {
-        // testy - przyspiesz od 0 do 100% a potem zwolnij:
             eng_left.move(0);
             eng_right.move(0);
-            wait(1);
-            srand( time( NULL ) );
-            liczba = (std::rand() % 200 ) - 100;
+            s= pc.getc();
+            pc.printf("%s  \n", s);
+            //pc.putc(s);
+            
+            /*
             eng_left.move(liczba);
             eng_right.move(liczba);
             wait(5);
-            if (liczba==0){
-                pc.printf("%f", time(NULL));
-                pc.printf("Nie ma wiatru, wiec stoje w miejscu.");
+            
+            if ((liczbaL==0) && (liczbaP==0)) {
+                pc.printf("Pale gume w miejscu bo kazali mi stac");
+                
+                }
+            else if ((liczbaL>0)&& (liczbaP>0)){
+            
+                pc.printf("Jade do przodu. Predkosc lewej strony to %d, a prawej strony to %d \n", liczbaL, liczbaP);
                 }
-            else if (liczba>0){
-                pc.printf("%f", time(NULL));
-                pc.printf("Jade do przodu. Predkosc w procentach to %d \n", liczba);
+                
+            else if ((liczbaL<0)&& (liczbaP<0)){
+                 pc.printf("Jade do tyłu. Predkosc lewej strony to %d, a prawej strony to %d \n", liczbaL, liczbaP);
+                
                 }
-            else {
-                pc.printf("%f", time(NULL));
-                pc.printf("Jade do tylu. Predkosc w procentach to %d \n", liczba);
+            else if ((liczbaL>=0)&& (liczbaP<=0)){
+                 pc.printf("Obracam sie w prawo. Predkosc lewej strony to %d, a prawej strony to %d \n", liczbaL, liczbaP);
                 }
-        
+            else if  ((liczbaL<=0)&& (liczbaP>=0)){
+                pc.printf("Obracam sie w lewo. Predkosc lewej strony to %d, a prawej strony to %d \n", liczbaL, liczbaP);
+                }
+            */     
     }
 
 }
\ No newline at end of file