FAQ | This is a LIVE service | Changelog

Skip to content
Snippets Groups Projects
Commit 2f613907 authored by ayush1301's avatar ayush1301
Browse files

Added more conditions, i.e., Junction ramps (good)

parent b44d49b4
No related branches found
No related tags found
No related merge requests found
......@@ -4,7 +4,7 @@
uint8_t regions[2] = {BACKWARD, FORWARD};
uint8_t regions_opposite[2] = {FORWARD, BACKWARD};
int region = 1;
#define floating_avg_num 1
#define floating_avg_num 3
int button_val = 0;
int button_port = 0;
......@@ -18,7 +18,7 @@ Adafruit_DCMotor *motors[] = {AFMS.getMotor(3), AFMS.getMotor(4)};
#define white 1
#define black 0
#define num_IR 4
int IR_threshold[num_IR] = {200, 200, 1024, 1024};
int IR_threshold[num_IR] = {300, 300, 300, 300};
float IR_avgs[num_IR] = {0}; //LRFB
int IR_colours[num_IR] = {0};
int IR_locns[num_IR] = {A0, A3, A1, A2};
......@@ -66,12 +66,28 @@ void loop() {
move_one_motor(motors, 200, right);
Serial.println("TURN RIGHT");
}
else if (IR_check_val == 3) {
Serial.println("Junction");
}
else if (IR_check_val == 4) {
Serial.println("Ramp off");
}
else if (IR_check_val == 5) {
Serial.println("Ramp on");
}
else {
Serial.println("Else block fml");
/*
for(int j = 0; j < 2; j++) {
motors[j]->setSpeed(0);
}
while (1);
*/
for(int j = 0; j < num_IR; j++) {
Serial.print(IR_avgs[j]);
Serial.print(" -> ");
}
Serial.println();
//while (1);
}
button_val = digitalRead(button_port);
}
......@@ -111,9 +127,18 @@ int IR_check(int LRFB[]) {
else if (LRFB[0] == black && LRFB[1] == white) {
return 2;
}
else {
else if (LRFB[0] == white && LRFB[1] == white && LRFB[2] == white && LRFB[3] == white) {
return 3;
}
else if (LRFB[0] == black && LRFB[1] == black && LRFB[2] == white && LRFB[3] == black) {
return 4;
}
else if (LRFB[0] == black && LRFB[1] == black && LRFB[2] == black && LRFB[3] == white) {
return 5;
}
else {
return 6;
}
}
void update_IR_vals() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment