From bf3fb9487529dac766a7f8b10752610feba8d202 Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 10 Oct 2019 19:34:42 +0530 Subject: [PATCH 01/11] Delete shorter_path.ino --- Ashrumachan/shorter_path.ino | 129 ----------------------------------- 1 file changed, 129 deletions(-) delete mode 100644 Ashrumachan/shorter_path.ino diff --git a/Ashrumachan/shorter_path.ino b/Ashrumachan/shorter_path.ino deleted file mode 100644 index 129b61e..0000000 --- a/Ashrumachan/shorter_path.ino +++ /dev/null @@ -1,129 +0,0 @@ -#define a 2 -#define b 4 -#define a1 3 -#define b1 5 - -int d_1, d_2, d_3, d_4; -int s1, s2, s3, s4; -int count = 0, sf = 1, w = 0; -int x_val, y_val, x_motion, y_motion; -volatile int c = 0; -volatile int c1 = 0; -int x, y, arr[8][2] = {{0, 0}, {10, 0}, {10, 8}, {12, 8}, {12, 12}, {10, 12}, {10, 20}, {20, 20}}; -void motion(int x_val, int y_val); -void setup() { - pinMode(a, INPUT); - digitalWrite(a, HIGH); - pinMode(b, INPUT); - digitalWrite(b, HIGH); - - pinMode(a1, INPUT); - digitalWrite(a1, HIGH); - pinMode(b1, INPUT); - digitalWrite(b1, HIGH); - - pinMode(23, OUTPUT); - pinMode(25, OUTPUT); - pinMode(27, OUTPUT); - pinMode(29, OUTPUT); - pinMode(6, OUTPUT); - pinMode(7, OUTPUT); - pinMode(8, OUTPUT); - pinMode(9, OUTPUT); - - - attachInterrupt(digitalPinToInterrupt(2), func, RISING); - attachInterrupt(digitalPinToInterrupt(3), func1, RISING); - - Serial.begin(115200); -} - -void loop() -{ - Serial.print(c); - Serial.print(" "); - Serial.print(c1); - Serial.println(" "); - x = c / 100; - y = c1 / 100; - - if (count % 2 == 0) - { - if (x == 12) - { - do { - motion (-200, 0); - } - while (x != arr[count][0]); - - } - else { - do { - motion (200, 0); - } - while (x != arr[count][0]); - } - count++; - } - else - { - do { - motion (0, 200); - } - while (y != arr[count][1]); - count++; - } -} - - -void func() { - - int s = digitalRead(a); - int d = digitalRead(b); - if (d != s) { - c++ ; - } - - else { - c-- ; - } - -} - - -void func1() { - - int s1 = digitalRead(a1); - int d1 = digitalRead(b1); - if (d1 != s1) { - c1++ ; - } - - else { - c1-- ; - } - -} -void motion(int x_val, int y_val) -{ - x_motion = x_val; - y_motion = y_val; - - sf = 1; - s1 = sf * (0.1768 * x + 0.1768 * y + 0.25 * w); - s2 = sf * (0.1768 * x + 0.1768 * y + 0.25 * w); - s3 = sf * (-0.1768 * x - 0.1768 * y + 0.25 * w); - s4 = sf * (-0.1768 * x - 0.1768 * y + 0.25 * w); - d_1 = (s1 > 0 ? 1 : 0); - d_2 = (s2 > 0 ? 1 : 0); - d_3 = (s3 > 0 ? 1 : 0); - d_4 = (s4 > 0 ? 1 : 0); - digitalWrite(6, d_1); - digitalWrite(7, d_2); - digitalWrite(8, d_3); - digitalWrite(9, d_4); - analogWrite(23, s1); - analogWrite(25, s2); - analogWrite(27, s3); - analogWrite(29, s4); -} From 604f84d6b2412510e363ff4de3a7fa1a8d03fc57 Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 10 Oct 2019 19:34:59 +0530 Subject: [PATCH 02/11] Delete task2.ino --- Ashrumachan/task2.ino | 91 ------------------------------------------- 1 file changed, 91 deletions(-) delete mode 100644 Ashrumachan/task2.ino diff --git a/Ashrumachan/task2.ino b/Ashrumachan/task2.ino deleted file mode 100644 index cc215cd..0000000 --- a/Ashrumachan/task2.ino +++ /dev/null @@ -1,91 +0,0 @@ -#define enc_11 2 -#define enc_12 4 -#define enc_21 3 -#define enc_22 5 - -volatile int enc1_val = 0; -volatile int enc2_val = 0; -int x_counter, x_motion, y_counter, y_motion, X_motion, Y_motion, x_val, y_val, arr[2][2] = {{0, 0}, {10, 10}}; -int d_1, d_2, d_3, d_4; -int s1, s2, s3, s4; -int count = 0, sf = 1, w = 0; -void setup() { - pinMode(enc_11, INPUT); - digitalWrite(enc_11, HIGH); - pinMode(enc_12, INPUT); - digitalWrite(enc_12, HIGH); - - pinMode(enc_21, INPUT); - digitalWrite(enc_21, HIGH); - pinMode(enc_22, INPUT); - digitalWrite(enc_22, HIGH); - - attachInterrupt(digitalPinToInterrupt(2), func, RISING); - attachInterrupt(digitalPinToInterrupt(3), func1, RISING); - - Serial.begin(115200); -} - -void loop() -{ - Serial.print(enc1_val); - Serial.print(" "); - Serial.print(enc2_val); - Serial.print(" "); - x_counter = enc1_val / 100; - y_counter = enc2_val / 100; - - x_val = arr[1][0] - arr[0][0]; - y_val = arr[1][1] - arr[0][1]; - x_motion = map(x_motion, -x_val, x_val, 0, 255); - y_motion = map(y_motion, -y_val, y_val, 0, 255); - motion(x_motion, y_motion); - -} - - -void func() { - if (digitalRead(enc_12) != digitalRead(enc_11)) { - enc1_val++ ; - } - - else { - enc1_val-- ; - } - -} - - -void func1() { - if (digitalRead(enc_22) != digitalRead(enc_21)) { - enc2_val++ ; - } - - else { - enc2_val-- ; - } - -} -void motion(int x_motion, int y_motion) -{ - X_motion = x_motion ; - Y_motion = y_motion ; - - sf = 1; - s1 = sf * (0.1768 * X_motion + 0.1768 * Y_motion + 0.25 * w); - s2 = sf * (0.1768 * X_motion + 0.1768 * Y_motion + 0.25 * w); - s3 = sf * (-0.1768 * X_motion - 0.1768 * Y_motion + 0.25 * w); - s4 = sf * (-0.1768 * X_motion - 0.1768 * Y_motion + 0.25 * w); - d_1 = (s1 > 0 ? 1 : 0); - d_2 = (s2 > 0 ? 1 : 0); - d_3 = (s3 > 0 ? 1 : 0); - d_4 = (s4 > 0 ? 1 : 0); - digitalWrite(6, d_1); - digitalWrite(7, d_2); - digitalWrite(8, d_3); - digitalWrite(9, d_4); - analogWrite(23, s1); - analogWrite(25, s2); - analogWrite(27, s3); - analogWrite(29, s4); -} From c0ef23bad029d7ed7d996902f9eb4456f9120430 Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 10 Oct 2019 19:37:09 +0530 Subject: [PATCH 03/11] Add files via upload --- Ashrumachan/task2.ino | 89 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Ashrumachan/task2.ino diff --git a/Ashrumachan/task2.ino b/Ashrumachan/task2.ino new file mode 100644 index 0000000..5c809de --- /dev/null +++ b/Ashrumachan/task2.ino @@ -0,0 +1,89 @@ +#define enc_11 2 +#define enc_12 4 +#define enc_21 3 +#define enc_22 5 + +volatile int enc1_val = 0; +volatile int enc2_val = 0; +int x_counter, x_motion, y_counter, y_motion, X_motion, Y_motion, x_val, y_val, arr[2][2] = {{0, 0}, {10, 10}}; +int d_1, d_2, d_3, d_4; +int s1, s2, s3, s4; +int count = 0, sf = 1, w = 0,angle; +void setup() { + pinMode(enc_11, INPUT); + digitalWrite(enc_11, HIGH); + pinMode(enc_12, INPUT); + digitalWrite(enc_12, HIGH); + + pinMode(enc_21, INPUT); + digitalWrite(enc_21, HIGH); + pinMode(enc_22, INPUT); + digitalWrite(enc_22, HIGH); + + attachInterrupt(digitalPinToInterrupt(2), func, RISING); + attachInterrupt(digitalPinToInterrupt(3), func1, RISING); + + Serial.begin(115200); +} + +void loop() +{ + x_counter = enc1_val / 100; + y_counter = enc2_val / 100; + while (x_counter != arr[1][0] && y_counter != arr[1][1]) + { + x_val = arr[1][0] - x_counter; + y_val = arr[1][1] - y_counter; + angle = atan2(y_val, x_val); + x_motion = map((90 - angle), -90, 90, -255, 255); + y_motion = map(angle, -90, 90, -255, 255); + motion(x_motion, y_motion); + } +} + + +void func() { + if (digitalRead(enc_12) != digitalRead(enc_11)) { + enc1_val++ ; + } + + else { + enc1_val-- ; + } + +} + + +void func1() { + if (digitalRead(enc_22) != digitalRead(enc_21)) { + enc2_val++ ; + } + + else { + enc2_val-- ; + } + +} +void motion(int x_motion, int y_motion) +{ + X_motion = x_motion ; + Y_motion = y_motion ; + + sf = 1; + s1 = sf * (0.1768 * X_motion + 0.1768 * Y_motion + 0.25 * w); + s2 = sf * (0.1768 * X_motion + 0.1768 * Y_motion + 0.25 * w); + s3 = sf * (-0.1768 * X_motion - 0.1768 * Y_motion + 0.25 * w); + s4 = sf * (-0.1768 * X_motion - 0.1768 * Y_motion + 0.25 * w); + d_1 = (s1 > 0 ? 1 : 0); + d_2 = (s2 > 0 ? 1 : 0); + d_3 = (s3 > 0 ? 1 : 0); + d_4 = (s4 > 0 ? 1 : 0); + digitalWrite(6, d_1); + digitalWrite(7, d_2); + digitalWrite(8, d_3); + digitalWrite(9, d_4); + analogWrite(23, s1); + analogWrite(25, s2); + analogWrite(27, s3); + analogWrite(29, s4); +} From 917f676139eb2c7c7160721d6975dc54271690bc Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 10 Oct 2019 19:58:56 +0530 Subject: [PATCH 04/11] Add files via upload --- Ashrumachan/shorter_path.ino | 112 +++++++++++++++++++++++++++++++++++ 1 file changed, 112 insertions(+) create mode 100644 Ashrumachan/shorter_path.ino diff --git a/Ashrumachan/shorter_path.ino b/Ashrumachan/shorter_path.ino new file mode 100644 index 0000000..49718a5 --- /dev/null +++ b/Ashrumachan/shorter_path.ino @@ -0,0 +1,112 @@ +#define a 2 +#define b 4 +#define a1 3 +#define b1 5 + +int d_1, d_2, d_3, d_4; +int s1, s2, s3, s4; +int count = 0, sf = 1, w = 0,angle; +int x_val, y_val, x_motion, y_motion,x,y; +volatile int c = 0; +volatile int c1 = 0; +int x_counter, y_counter, arr[4][2] = {{0, 0}, {10, 8}, {12, 8}, {20, 20}}; +void motion(int x_val, int y_val); +void setup() { + pinMode(a, INPUT); + digitalWrite(a, HIGH); + pinMode(b, INPUT); + digitalWrite(b, HIGH); + + pinMode(a1, INPUT); + digitalWrite(a1, HIGH); + pinMode(b1, INPUT); + digitalWrite(b1, HIGH); + + pinMode(23, OUTPUT); + pinMode(25, OUTPUT); + pinMode(27, OUTPUT); + pinMode(29, OUTPUT); + pinMode(6, OUTPUT); + pinMode(7, OUTPUT); + pinMode(8, OUTPUT); + pinMode(9, OUTPUT); + + + attachInterrupt(digitalPinToInterrupt(2), func, RISING); + attachInterrupt(digitalPinToInterrupt(3), func1, RISING); + + Serial.begin(115200); +} + +void loop() +{ + x_counter = c / 100; + y_counter = c1 / 100; + + for (int i = 1; i <= 3; i++) + { + while (x_counter != arr[i][0] && y_counter != arr[i][1]) + { + x_val = arr[i][0] - x_counter; + y_val = arr[i][1] - y_counter; + angle = atan2(y_val, x_val); + x_motion = map((90 - angle), -90, 90, -255, 255); + y_motion = map(angle, -90, 90, -255, 255); + motion(x_motion, y_motion); + } + } +} + + + +void func() { + + int s = digitalRead(a); + int d = digitalRead(b); + if (d != s) { + c++ ; + } + + else { + c-- ; + } + +} + + +void func1() { + + int s1 = digitalRead(a1); + int d1 = digitalRead(b1); + if (d1 != s1) { + c1++ ; + } + + else { + c1-- ; + } + +} +void motion(int x_val, int y_val) +{ + x_motion = x_val; + y_motion = y_val; + + sf = 1; + s1 = sf * (0.1768 * x + 0.1768 * y + 0.25 * w); + s2 = sf * (0.1768 * x + 0.1768 * y + 0.25 * w); + s3 = sf * (-0.1768 * x - 0.1768 * y + 0.25 * w); + s4 = sf * (-0.1768 * x - 0.1768 * y + 0.25 * w); + d_1 = (s1 > 0 ? 1 : 0); + d_2 = (s2 > 0 ? 1 : 0); + d_3 = (s3 > 0 ? 1 : 0); + d_4 = (s4 > 0 ? 1 : 0); + digitalWrite(6, d_1); + digitalWrite(7, d_2); + digitalWrite(8, d_3); + digitalWrite(9, d_4); + analogWrite(23, s1); + analogWrite(25, s2); + analogWrite(27, s3); + analogWrite(29, s4); +} From 8bb2e2ed6befb971131aed84ff37f25332880390 Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 10 Oct 2019 21:50:24 +0530 Subject: [PATCH 05/11] Update task2.ino --- Ashrumachan/task2.ino | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Ashrumachan/task2.ino b/Ashrumachan/task2.ino index 5c809de..d25294b 100644 --- a/Ashrumachan/task2.ino +++ b/Ashrumachan/task2.ino @@ -66,14 +66,13 @@ void func1() { } void motion(int x_motion, int y_motion) { - X_motion = x_motion ; - Y_motion = y_motion ; + sf = 1; - s1 = sf * (0.1768 * X_motion + 0.1768 * Y_motion + 0.25 * w); - s2 = sf * (0.1768 * X_motion + 0.1768 * Y_motion + 0.25 * w); - s3 = sf * (-0.1768 * X_motion - 0.1768 * Y_motion + 0.25 * w); - s4 = sf * (-0.1768 * X_motion - 0.1768 * Y_motion + 0.25 * w); + s1 = sf * (0.1768 * x_motion + 0.1768 * y_motion + 0.25 * w); + s2 = sf * (0.1768 * x_motion + 0.1768 * y_motion + 0.25 * w); + s3 = sf * (-0.1768 * x_motion - 0.1768 * y_motion + 0.25 * w); + s4 = sf * (-0.1768 * x_motion - 0.1768 * y_motion + 0.25 * w); d_1 = (s1 > 0 ? 1 : 0); d_2 = (s2 > 0 ? 1 : 0); d_3 = (s3 > 0 ? 1 : 0); From 7ba9cc3bf06243ebd28de4cb4c653e980c991308 Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 10 Oct 2019 21:54:13 +0530 Subject: [PATCH 06/11] Update task2.ino --- Ashrumachan/task2.ino | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Ashrumachan/task2.ino b/Ashrumachan/task2.ino index d25294b..16c4848 100644 --- a/Ashrumachan/task2.ino +++ b/Ashrumachan/task2.ino @@ -35,8 +35,16 @@ void loop() x_val = arr[1][0] - x_counter; y_val = arr[1][1] - y_counter; angle = atan2(y_val, x_val); + + if(angle==45){ + x_motion =255; + y_motion =255; + } + else + { x_motion = map((90 - angle), -90, 90, -255, 255); y_motion = map(angle, -90, 90, -255, 255); + } motion(x_motion, y_motion); } } From 3244b5c95c68e1a32a5f1b66879303b0b365cea9 Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 10 Oct 2019 22:02:53 +0530 Subject: [PATCH 07/11] Update shorter_path.ino --- Ashrumachan/shorter_path.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ashrumachan/shorter_path.ino b/Ashrumachan/shorter_path.ino index 49718a5..19b0239 100644 --- a/Ashrumachan/shorter_path.ino +++ b/Ashrumachan/shorter_path.ino @@ -49,7 +49,7 @@ void loop() { x_val = arr[i][0] - x_counter; y_val = arr[i][1] - y_counter; - angle = atan2(y_val, x_val); + angle = atan(y_val, x_val); x_motion = map((90 - angle), -90, 90, -255, 255); y_motion = map(angle, -90, 90, -255, 255); motion(x_motion, y_motion); From da9d861ef0f57529feab7c553dc064e0fdcf38ea Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 10 Oct 2019 22:03:34 +0530 Subject: [PATCH 08/11] Update task2.ino --- Ashrumachan/task2.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ashrumachan/task2.ino b/Ashrumachan/task2.ino index 16c4848..26bcbe0 100644 --- a/Ashrumachan/task2.ino +++ b/Ashrumachan/task2.ino @@ -34,7 +34,7 @@ void loop() { x_val = arr[1][0] - x_counter; y_val = arr[1][1] - y_counter; - angle = atan2(y_val, x_val); + angle = atan(y_val, x_val); if(angle==45){ x_motion =255; From 26d32215982a5d2a50f1ecbaeee68184fd6baacd Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Sun, 13 Oct 2019 11:39:30 +0530 Subject: [PATCH 09/11] Update shorter_path.ino --- Ashrumachan/shorter_path.ino | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Ashrumachan/shorter_path.ino b/Ashrumachan/shorter_path.ino index 19b0239..524dfba 100644 --- a/Ashrumachan/shorter_path.ino +++ b/Ashrumachan/shorter_path.ino @@ -9,7 +9,7 @@ int count = 0, sf = 1, w = 0,angle; int x_val, y_val, x_motion, y_motion,x,y; volatile int c = 0; volatile int c1 = 0; -int x_counter, y_counter, arr[4][2] = {{0, 0}, {10, 8}, {12, 8}, {20, 20}}; +int x_counter=0, y_counter=0,x_count,y_count, arr[4][2] = {{0, 0}, {10, 8}, {12, 8}, {20, 20}}; void motion(int x_val, int y_val); void setup() { pinMode(a, INPUT); @@ -40,8 +40,10 @@ void setup() { void loop() { - x_counter = c / 100; - y_counter = c1 / 100; + x_count= c / 100; + x_counter = x_counter+x_count; + y_count= c1 / 100; + y_counter = y_counter+y_count; for (int i = 1; i <= 3; i++) { @@ -54,6 +56,8 @@ void loop() y_motion = map(angle, -90, 90, -255, 255); motion(x_motion, y_motion); } + c=0; + c1=0; } } From 44c85666e4bbff594c20b4200feb4f7b1683c03d Mon Sep 17 00:00:00 2001 From: Asrumochan Parida <55292217+Asrumochan@users.noreply.github.com> Date: Thu, 1 Oct 2020 01:21:21 +0530 Subject: [PATCH 10/11] Update mapping_encoder.ino --- Ashrumachan/mapping_encoder.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ashrumachan/mapping_encoder.ino b/Ashrumachan/mapping_encoder.ino index 685e478..c7e39f8 100644 --- a/Ashrumachan/mapping_encoder.ino +++ b/Ashrumachan/mapping_encoder.ino @@ -3,7 +3,7 @@ #define enc_21 3 #define enc_22 5 -volatile int enc1_val = 0; +volatile int enc1_val = 0 volatile int enc2_val = 0; int x_counter,x_motion,y_counter,y_motion; void setup() { From e03e17b1547754ebc8f49930ba2e1f42e96ee547 Mon Sep 17 00:00:00 2001 From: Prayash77 <56315251+Prayash77@users.noreply.github.com> Date: Sun, 3 Oct 2021 21:54:42 +0530 Subject: [PATCH 11/11] Update Tasks.txt --- Ashrumachan/Tasks.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Ashrumachan/Tasks.txt b/Ashrumachan/Tasks.txt index 7bfe392..5f2745a 100644 --- a/Ashrumachan/Tasks.txt +++ b/Ashrumachan/Tasks.txt @@ -1,2 +1,2 @@ -5th October 2019 +5th october 2019 Mapping code using encoders