aboutsummaryrefslogtreecommitdiff
path: root/doc/Lesson 5 Line Tracking Car
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2017-08-26 20:33:02 +0200
committerDimitri Sokolyuk <demon@dim13.org>2017-08-26 20:33:02 +0200
commitba216919262d7f888bfb99debf81babe1ce88e0e (patch)
tree16c19610a7a3a77c97b99a63f6ba85d11ebde4ec /doc/Lesson 5 Line Tracking Car
parentd80736ab6e8e3cad2f1a30c6eaba2d6883dbe967 (diff)
Move lessons to doc
Diffstat (limited to 'doc/Lesson 5 Line Tracking Car')
-rwxr-xr-xdoc/Lesson 5 Line Tracking Car/Lesson 5 Line tracking car.avibin0 -> 14721626 bytes
-rwxr-xr-xdoc/Lesson 5 Line Tracking Car/Line tracking car.pdfbin0 -> 496571 bytes
-rwxr-xr-xdoc/Lesson 5 Line Tracking Car/Line_tracking_car/Line_tracking_car.ino105
-rwxr-xr-xdoc/Lesson 5 Line Tracking Car/~$ne-Tracking Car.docxbin0 -> 162 bytes
4 files changed, 105 insertions, 0 deletions
diff --git a/doc/Lesson 5 Line Tracking Car/Lesson 5 Line tracking car.avi b/doc/Lesson 5 Line Tracking Car/Lesson 5 Line tracking car.avi
new file mode 100755
index 0000000..2b91472
--- /dev/null
+++ b/doc/Lesson 5 Line Tracking Car/Lesson 5 Line tracking car.avi
Binary files differ
diff --git a/doc/Lesson 5 Line Tracking Car/Line tracking car.pdf b/doc/Lesson 5 Line Tracking Car/Line tracking car.pdf
new file mode 100755
index 0000000..dad26e4
--- /dev/null
+++ b/doc/Lesson 5 Line Tracking Car/Line tracking car.pdf
Binary files differ
diff --git a/doc/Lesson 5 Line Tracking Car/Line_tracking_car/Line_tracking_car.ino b/doc/Lesson 5 Line Tracking Car/Line_tracking_car/Line_tracking_car.ino
new file mode 100755
index 0000000..d3dc773
--- /dev/null
+++ b/doc/Lesson 5 Line Tracking Car/Line_tracking_car/Line_tracking_car.ino
@@ -0,0 +1,105 @@
+//www.elegoo.com
+//2016.09.12
+
+int in1=9;
+int in2=8;
+int in3=7;
+int in4=6;
+int ENA=10;
+int ENB=5;
+ int ABS=130;
+ void _mForward()
+{
+ analogWrite(ENA,ABS);
+ analogWrite(ENB,ABS);
+ digitalWrite(in1,LOW);
+ digitalWrite(in2,HIGH);
+ digitalWrite(in3,LOW);
+ digitalWrite(in4,HIGH);
+ Serial.println("go forward!");
+}
+
+void _mBack()
+{
+ analogWrite(ENA,ABS);
+ analogWrite(ENB,ABS);
+ digitalWrite(in1,HIGH);
+ digitalWrite(in2,LOW);
+ digitalWrite(in3,HIGH);
+ digitalWrite(in4,LOW);
+ Serial.println("go back!");
+}
+
+void _mleft()
+{
+ analogWrite(ENA,ABS);
+ analogWrite(ENB,ABS);
+ digitalWrite(in1,LOW);
+ digitalWrite(in2,HIGH);
+ digitalWrite(in3,HIGH);
+ digitalWrite(in4,LOW);
+ Serial.println("go left!");
+}
+
+void _mright()
+{
+ analogWrite(ENA,ABS);
+ analogWrite(ENB,ABS);
+ digitalWrite(in1,HIGH);
+ digitalWrite(in2,LOW);
+ digitalWrite(in3,LOW);
+ digitalWrite(in4,HIGH);
+ Serial.println("go right!");
+}
+void _mStop()
+{
+ digitalWrite(ENA,LOW);
+ digitalWrite(ENB,LOW);
+ Serial.println("Stop!");
+}
+
+void setup()
+{
+ Serial.begin(9600);
+}
+
+void loop() {
+ int num1,num2,num3;
+ num1=digitalRead(11);
+ num2=digitalRead(4);
+ num3=digitalRead(2);
+ if((num1==0)&&num2&&num3)
+ {
+ _mleft(); //The sensor detected that right car turn left immediately when it meets black line
+ delay(2);
+ while(1){
+ num2=digitalRead(2); //Cycle to judge degree of intermediate sensor,
+ if(num2==1)
+ { _mleft(); //If num2==1 does not go to the middle position, continue to turn left.
+ delay(2);}
+ else
+ break; //Detection of num2==0 instructions turned over, out of the loop, detection of three sensors’ statusand then make appropriate action
+ } //The following and so on
+ }
+
+ else if(num2&&num1&&(num3==0))
+ {
+ _mright();
+ delay(2);
+ while(1)
+ {
+ num2=digitalRead(2);
+ if(num2==1){
+ _mright();
+ delay(2);}
+ else
+ break;
+ }
+ }
+ else
+ {
+ _mForward();
+ delay(2);
+ }
+}
+
diff --git a/doc/Lesson 5 Line Tracking Car/~$ne-Tracking Car.docx b/doc/Lesson 5 Line Tracking Car/~$ne-Tracking Car.docx
new file mode 100755
index 0000000..f3b4136
--- /dev/null
+++ b/doc/Lesson 5 Line Tracking Car/~$ne-Tracking Car.docx
Binary files differ