diff --git a/Home.md b/Home.md index 568b406..69ef269 100644 --- a/Home.md +++ b/Home.md @@ -1,6 +1,5 @@ //KWDIKAS AUTONOMOU AMAKSIOU - - +``` #include // Includes servo library. // defines pins numbers const int trigPin = 12; @@ -12,7 +11,9 @@ const int rm2=4; const int servoPin=13; Servo myservo; +``` +``` // orizw katholikes metavlites gia na tis peirazw apo tis sunartiseis kai na boroun na allazoun kai timh long duration; int distance; @@ -20,7 +21,10 @@ int distance_f; //apostash tou amaksiou apo antikeimeno eutheia int distance_r; //apostash tou amaksiou apo antikeimeno deksia int distance_l; //apostash tou amaksiou apo antikeimeno aristera int maxLowDistance=20; //elaxisth apostash sthn opia ama vrethw stamataw +``` + +``` void setup() { pinMode(trigPin, OUTPUT); pinMode(echoPin, INPUT); @@ -35,6 +39,11 @@ myservo.write(90); Serial.begin(9600); // Starts the serial communication } +``` + + +``` + ****void loop() { distance_f=ping(); //Psaxnw gia thn apostash pou exw brosta mou if(distance_f > maxLowDistance){ //An einai megaluteri apo 20cm h apostash tou amaksiou apo to prwto ebodio (diladi thn elaxisth apostash pou tou exw orisei) tote tha paei eutheia @@ -60,9 +69,10 @@ Serial.begin(9600); // Starts the serial communication } } +``` - +``` //thn exw gia debug ayth thn sunartisi gia na dw an leitourgei o esthitiras swsta kai an katagrafontai oi times gia tis apostaseis eutheia deksia kai aristera void displayDistance(){ Serial.print("Right Distance : "); @@ -76,12 +86,16 @@ void displayDistance(){ Serial.println(""); } +``` + + +``` //Logo tou oloklirwmenou LM298 borw na diaxiristw kai pio eukola to amaksaki mou //exw ftiaksei 5 sunartiseis gia na boreis na pigainei brosta pisw aristera deksia kai na stamataei //shnarthsh gia na pigenei brosta to amaksi -****void front(){ +***void front(){ Serial.println("Forward Move"); //vazw se leitourgeia kai tous 4 troxous digitalWrite(lm2,HIGH); digitalWrite(rm2,HIGH); @@ -126,6 +140,9 @@ digitalWrite(rm1,LOW); digitalWrite(rm1,LOW); digitalWrite(rm2,LOW); } +``` + +``` ****void get_Distance(){ myservo.write(0); //gurnaw to servo mou deksia gia na boresei na parei metrisi o aisthitiras @@ -157,6 +174,10 @@ digitalWrite(rm1,LOW); myservo.write(90); } +``` + + +``` //thn xrisimopoiw gia na parw tis metriseis tou aisthitira kai na kanw thn katalili metatropi. ****int ping(){ // Clears the trigPin @@ -172,4 +193,5 @@ digitalWrite(rm1,LOW); distance= duration*0.034/2; // Prints the distance on the Serial Monitor return distance; -} \ No newline at end of file +} +``` \ No newline at end of file