Commit d456b951 authored by Micael Couceiro's avatar Micael Couceiro
Browse files

Central sensor is now being used in the main code.

parent 94291cc7
......@@ -9,11 +9,12 @@ long int myrate = 500;
void setup() {
// start serial port for debugging
Serial.begin(9600);
}
void loop() {
// main loop goes here
while(loop_rate()){
switch(state){
......@@ -39,7 +40,7 @@ void loop() {
int LOST(){
float *range = myrobot.getIRranges();
if ((range[0] >= 20) && (range[2] >= 20)){
if ((range[0] >= 20) && (range[1] >= 20) && (range[2] >= 20)){
int pwm[2] = {150,150};
myrobot.moveRobot(pwm);
}
......@@ -50,7 +51,7 @@ int LOST(){
int CCW(){
float *range = myrobot.getIRranges();
if ((range[0] < 20) || (range[2] < 20)){
if ((range[0] < 20) || (range[1] < 20) || (range[2] < 20)){
int pwm[2] = {-150,150};
myrobot.moveRobot(pwm);
}
......@@ -61,7 +62,7 @@ int CCW(){
int WALL1(){
float *range = myrobot.getIRranges();
if (range[2] >= 20){
if ((range[1] >= 20) && (range[2] >= 20)){
int pwm1[2] = {150,150};
myrobot.moveRobot(pwm1);
delay(myrate);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment