Differences

This shows you the differences between two versions of the page.

Link to this comparison view

pm:prj2022:robert:mini_wall-e [2022/05/27 18:59]
ovidiu.ghibea [How It Works]
pm:prj2022:robert:mini_wall-e [2022/05/27 19:33] (current)
ovidiu.ghibea [Jurnal]
Line 66: Line 66:
 pinMode(echoPin,​ INPUT); ​         //set echo pin as input to capture reflected waves pinMode(echoPin,​ INPUT); ​         //set echo pin as input to capture reflected waves
 </​code>​ </​code>​
-The loop() ​part of the program is made out of two scenarios. \\ +In loop() ​functionget the distance from HC-SR04 and based on the distance move the motor directionThe distance will show the object distance coming in front of the robot. The Distance is taken by bursting a beam of ultrasonic up to 10 us and receiving ​it after 10usTo learn more about measuring distance using Ultrasonic ​sensor and Arduinofollow ​the link.
- +
-In the first scenario, the switch is off (The convention for this project is that if the microswitch is off, the circuit is activeIf the switch is on, then the circuit is off. The reason for this being the outer design ​of the toy as well as the desire ​to make it movie accurate) and the program begins the arming sequenceIt receives the measurement from the movement ​sensor and if the measurement is smaller than the chosen valueit keeps on with the arming sequence. If the measurement is greater than the chosen value, it stops the previous sequence by stopping track 1 and starts the detonation sequence by playing track 2 and turning all LED’s on HIGH.+
 <code cpp> <code cpp>
-// Start communication with DFPlayer Mini +digitalWrite(trigPin, LOW); 
- +delayMicroseconds(2);   ​ 
-    // Set volume to a value between ​(0 to 30) +digitalWrite(trigPin, HIGH); ​    ​// send waves for 10 us 
-    player.volume(30); +delayMicroseconds(10); 
- +duration ​= pulseIn(echoPin, HIGH); // receive reflected waves 
-  if (digitalRead(BUTTON) == LOW ){ +distance = duration ​58.2;   ​// convert ​to distance 
-      player.play(1); // play the arming sequence +delay(10);
-      digitalWrite(LEDRED, HIGH);//switch armed LED (red) on +
-  } +
-   +
-  if (digitalRead(BUTTON== LOW && sequenceNumber == 0) +
-  { +
-    long measurement ​=pulseIn (SENSOR, HIGH); //get measurement from teh sensor +
-    ​Serial.println(measurement);​ +
-    if (measurement > 1000) +
-    { // measurement checks +
-      player.stop(); +
-     player.play(2); //playing detonating sequence +
-     sequenceNumber = 0; +
-     digitalWrite(LEDRED,​ HIGH); +
-      digitalWrite(LEDRIGHT,​ HIGH); +
-      digitalWrite(LEDMIDDLE,​ HIGH); +
-      digitalWrite(LEDLEFT,​ HIGH); +
-     while(digitalRead(BUTTON)==LOW){ // give a chance ​to turn off the toy +
-     ​delay(10000); +
-     player.stop();​ +
-     digitalWrite(LEDRED,​ LOW); +
-        digitalWrite(LEDRIGHT,​ LOW); +
-        digitalWrite(LEDMIDDLE,​ LOW); +
-        digitalWrite(LEDLEFT,​ LOW); +
-     } +
-    } +
-    else +
-    { // measuremnt does not check +
-      delay(time);​ +
-      Sequence(false,​ true, true); // continu with arming sequence +
-      sequenceNumber++;​ +
-    } +
-  }+
 </​code> ​ </​code> ​
-The second scenario is when the switch ​is on, so the circuit ​is not active.+If the distance ​is greater than the defined distance means there is not obstacle in its path and it will moving in forward direction.
 <code cpp> <code cpp>
-if (digitalRead(BUTTON== HIGH) // toy is turned off +if (distance > 19            
-  +            
-    ​sequenceNumber = 0; +            digitalWrite(fwdright7HIGH);                    // move forward 
-    player.stop();​ +            digitalWrite(revright6, LOW); 
- digitalWrite(LEDREDLOW); +            digitalWrite(fwdleft5HIGH);                                 
-    digitalWrite(LEDRIGHT, LOW); +            digitalWrite(revleft4, LOW);                                                       ​ 
-    digitalWrite(LEDMIDDLELOW); +            }
-    digitalWrite(LEDLEFT, LOW); +
-   +
 </​code>​ </​code>​
-Additionally,​ depending on the length of track 1 used in the arming sequence, we will choose ​number of times the respective ​if{} statement will be repeated. In this case it, is repeated 12 times +If the distance is less than the defined distance to avoid obstacle means there is some obstacle ahead. So in this situation robot will stop for while and movebackwards after that again stop for a while and then take turn to another direction. 
 +<code cpp> 
 +if (distance < 18) 
 +             { 
 +             ​digitalWrite(fwdright7LOW);  //​Stop ​                
 +             ​digitalWrite(revright6,​ LOW); 
 +             ​digitalWrite(fwdleft5,​ LOW);                                 
 +             ​digitalWrite(revleft4,​ LOW); 
 +             ​delay(500);​ 
 +             ​digitalWrite(fwdright7,​ LOW);      //​movebackword ​         
 +             ​digitalWrite(revright6,​ HIGH); 
 +             ​digitalWrite(fwdleft5,​ LOW);                                 
 +             ​digitalWrite(revleft4,​ HIGH); 
 +             ​delay(500);​ 
 +             ​digitalWrite(fwdright7,​ LOW);  //​Stop ​                
 +             ​digitalWrite(revright6,​ LOW); 
 +             ​digitalWrite(fwdleft5,​ LOW);                                 
 +             ​digitalWrite(revleft4,​ LOW);   
 +             ​delay(100); ​  
 +             ​digitalWrite(fwdright7,​ HIGH); ​       
 +             ​digitalWrite(revright6,​ LOW);    
 +             ​digitalWrite(revleft4,​ LOW);                                  
 +             ​digitalWrite(fwdleft5,​ LOW);   
 +             ​delay(500);​ 
 +            } 
 +</​code>​  
 +This is how a robot can avoid obstacles in its path without getting stuck anywhere.
 ===== Rezultate Obţinute ===== ===== Rezultate Obţinute =====
  
Line 132: Line 121:
 ===== Concluzii ===== ===== Concluzii =====
  
 +After finishing the project, I learned that:\\
 +  *While the code is simple, the hardest part was the making of the chasis.
 +
 +  *Some parts have very tough bolts to unscrew which led to a lot of wasted time
 +
 +  *It was fun to see it work after all the effort put in it 
 + 
 ===== Download ===== ===== Download =====
  
-<note warning>​ +{{:pm:​prj2022:​robert:​obsav.rar|Source Code}}
-O arhivă (sau mai multe dacă este cazul) cu fişierele obţinute în urma realizării proiectuluisurse, scheme, etc. Un fişier README, un ChangeLog, un script de compilare şi copiere automată pe uC crează întotdeauna o impresie bună ;-).+
  
-Fişierele se încarcă pe wiki folosind facilitatea **Add Images or other files**. Namespace-ul în care se încarcă fişierele este de tipul **:pm:prj20??:c?** sau **:pm:prj20??:​c?:​nume_student** (dacă este cazul). **Exemplu:​** Dumitru Alin, 331CC -> **:​pm:​prj2009:​cc:​dumitru_alin**. +{{:pm:prj2022:robert:rob.png?linkonly|Electric Diagram}}
-</​note>​+
  
-===== Jurnal ===== 
- 
-<note tip> 
-Puteți avea și o secțiune de jurnal în care să poată urmări asistentul de proiect progresul proiectului. 
-</​note>​ 
  
 ===== Bibliografie/​Resurse ===== ===== Bibliografie/​Resurse =====
  
-<​note>​ +  *[[https://​store.arduino.cc/​products/​arduino-uno-rev3/​|Arduino UNO]] 
-Listă cu documente, datasheet-uri, resurse Internet folosite, eventual grupate pe **Resurse Software** şi **Resurse Hardware**. +  ​*[[https://​www.newark.com/​stmicroelectronics/​l298n/​ic-bridge-driver-dual-298/​dp/​10WX1394?​rpsku=rel1:​32M1527&​isexcsku=false|SparkFun Dual H-Bridge motor drivers L298]] 
-</note>+  ​*[[https:​//​www.sparkfun.com/​products/​15569|SparkFun Ultrasonic Sensor - HC-SR04]]
  
 <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​ <​html><​a class="​media mediafile mf_pdf"​ href="?​do=export_pdf">​Export to PDF</​a></​html>​
  
  
pm/prj2022/robert/mini_wall-e.1653667165.txt.gz · Last modified: 2022/05/27 18:59 by ovidiu.ghibea
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0