this robot uses ultrasonic sensors to detect the obstacles and the servo motor acts as the neck for the robot in checking the obstacles in right and left directions
Dependencies: HCSR04 Servo mbed
Fork of Obstacle_avoidance by
Revision 1:43568a9d4323, committed 2017-03-24
- Comitter:
- monikakakani
- Date:
- Fri Mar 24 01:02:04 2017 +0000
- Parent:
- 0:a87600bebf7b
- Commit message:
- obstacle avoiding and detecting robot using ultrasonic and servo
Changed in this revision
diff -r a87600bebf7b -r 43568a9d4323 Makefile --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Makefile Fri Mar 24 01:02:04 2017 +0000 @@ -0,0 +1,88 @@ +# This file was automagically generated by mbed.org. For more information, +# see http://mbed.org/handbook/Exporting-to-GCC-ARM-Embedded + +GCC_BIN = +PROJECT = Obstacle_avoider +OBJECTS = ./main.o ./Servo/Servo.o ./HCSR04/hcsr04.o +SYS_OBJECTS = ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/board.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/cmsis_nvic.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/mbed_overrides.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/retarget.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/startup_MK64F12.o ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/system_MK64F12.o +INCLUDE_PATHS = -I. -I./Servo -I./HCSR04 -I./mbed -I./mbed/TARGET_K64F -I./mbed/TARGET_K64F/TARGET_Freescale -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/common -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/common/phyksz8081 -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/clock -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/enet -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/interrupt -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/pit -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/drivers/pit/common -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/adc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/can -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/dac -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/dmamux -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/dspi -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/edma -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/enet -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/flextimer -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/gpio -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/i2c -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/llwu -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/lptmr -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/lpuart -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/mcg -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/mpu -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/osc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/pdb -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/pit -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/pmc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/port -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/rcm -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/rtc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/sai -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/sdhc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/sim -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/smc -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/uart -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/hal/wdog -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_KPSDK_CODE/utilities -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/MK64F12 -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/TARGET_FRDM -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/device -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/device/MK64F12 -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/device/device -I./mbed/TARGET_K64F/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_MCU_K64F/device/device/MK64F12 -I./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM +LIBRARY_PATHS = -L./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM +LIBRARIES = -lmbed +LINKER_SCRIPT = ./mbed/TARGET_K64F/TOOLCHAIN_GCC_ARM/K64FN1M0xxx12.ld + +############################################################################### +AS = $(GCC_BIN)arm-none-eabi-as +CC = $(GCC_BIN)arm-none-eabi-gcc +CPP = $(GCC_BIN)arm-none-eabi-g++ +LD = $(GCC_BIN)arm-none-eabi-gcc +OBJCOPY = $(GCC_BIN)arm-none-eabi-objcopy +OBJDUMP = $(GCC_BIN)arm-none-eabi-objdump +SIZE = $(GCC_BIN)arm-none-eabi-size + +ifeq ($(HARDFP),1) + FLOAT_ABI = hard +else + FLOAT_ABI = softfp +endif + + +CPU = -mcpu=cortex-m4 -mthumb -mfpu=fpv4-sp-d16 -mfloat-abi=$(FLOAT_ABI) +CC_FLAGS = $(CPU) -c -g -fno-common -fmessage-length=0 -Wall -Wextra -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer -MMD -MP +CC_SYMBOLS = -DTARGET_RTOS_M4_M7 -DTARGET_FF_ARDUINO -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -DMBED_BUILD_TIMESTAMP=1459186138.8 -DTARGET_KPSDK_MCUS -DTARGET_KPSDK_CODE -DTARGET_FRDM -DTARGET_CORTEX_M -DCPU_MK64FN1M0VMD12 -D__FPU_PRESENT=1 -DTARGET_Freescale -DTARGET_M4 -D__MBED__=1 -DTARGET_K64F -DTARGET_LIKE_CORTEX_M4 -D__CORTEX_M4 -DFSL_RTOS_MBED -DTARGET_MCU_K64F -DARM_MATH_CM4 -DTARGET_LIKE_MBED + +LD_FLAGS = $(CPU) -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,--wrap,main -Wl,-Map=$(PROJECT).map,--cref +LD_SYS_LIBS = -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys + + +ifeq ($(DEBUG), 1) + CC_FLAGS += -DDEBUG -O0 +else + CC_FLAGS += -DNDEBUG -Os +endif + +.PHONY: all clean lst size + +all: $(PROJECT).bin $(PROJECT).hex size + + +clean: + rm -f $(PROJECT).bin $(PROJECT).elf $(PROJECT).hex $(PROJECT).map $(PROJECT).lst $(OBJECTS) $(DEPS) + + +.asm.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< +.s.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< +.S.o: + $(CC) $(CPU) -c -x assembler-with-cpp -o $@ $< + +.c.o: + $(CC) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu99 $(INCLUDE_PATHS) -o $@ $< + +.cpp.o: + $(CPP) $(CC_FLAGS) $(CC_SYMBOLS) -std=gnu++98 -fno-rtti $(INCLUDE_PATHS) -o $@ $< + + + +$(PROJECT).elf: $(OBJECTS) $(SYS_OBJECTS) + $(LD) $(LD_FLAGS) -T$(LINKER_SCRIPT) $(LIBRARY_PATHS) -o $@ $^ $(LIBRARIES) $(LD_SYS_LIBS) $(LIBRARIES) $(LD_SYS_LIBS) + + +$(PROJECT).bin: $(PROJECT).elf + $(OBJCOPY) -O binary $< $@ + +$(PROJECT).hex: $(PROJECT).elf + @$(OBJCOPY) -O ihex $< $@ + +$(PROJECT).lst: $(PROJECT).elf + @$(OBJDUMP) -Sdh $< > $@ + +lst: $(PROJECT).lst + +size: $(PROJECT).elf + $(SIZE) $(PROJECT).elf + +DEPS = $(OBJECTS:.o=.d) $(SYS_OBJECTS:.o=.d) +-include $(DEPS) + +
diff -r a87600bebf7b -r 43568a9d4323 Motordriver.lib --- a/Motordriver.lib Sat May 18 04:39:55 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/littlexc/code/Motordriver/#3110b9209d3c
diff -r a87600bebf7b -r 43568a9d4323 TextLCD.lib --- a/TextLCD.lib Sat May 18 04:39:55 2013 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/simon/code/TextLCD/#44f34c09bd37
diff -r a87600bebf7b -r 43568a9d4323 main.cpp --- a/main.cpp Sat May 18 04:39:55 2013 +0000 +++ b/main.cpp Fri Mar 24 01:02:04 2017 +0000 @@ -1,229 +1,296 @@ -/* Megha Sharma, Rishabh Sehgal, Ragheshwar Singh Ranawat ,E.C.E.D NIT Hamirpur - - OBSTACLE AVOIDING ROBOT USING ULTRASONIC SENSOR HCSR04 - -In this project LPC 1768 embed board along with NGX Expresso baseboard are successfuly used to make an obstacle avoiding/ -self navigating robot which makes use of Ultrasonic Sensor HCSR04 for obstacle detection and Ranging. The maximum range of -Ultrasonic sensor is about 3-4 meters. A program called "ping" sends a serial trigger pulse of 10 nS to the Trigger pin of -HCSR04 and on receiving the trigger HCSR04 beams out an 8 cycle Sonic burst. Then Echo pulse is received by the Ultrasonic sensor -upto 25ms. On receiving the Echo pulse distance is calculated. The HCSR04 is mounted Axially on a servo motor. Initially the HCSR04 -is kept in a straight direction. Motors make bot move in forward direction and continuosly calculating the distance of the -nearest obstacle in the forward direction. After seeing a distance at less than a "Constraint Value" (i.e. 10 cm here), -the robot goes in a scan mode. It first moves the Servo Motor to the Right, waits for 2 seconds and stores the value of -Distance in right direction in "rightscanval" variable.Then it comes back to centre position. Now it moves towards the -Left direction, waits for 2 seconds and stores the value of Distance in "leftscanval" variable. Then it comes back to the -centre position. Now it does the comparison of the two variables to determine in which direction it should move. It -successfully turns towards the direction with the farthest distance of obstacle. - -Again the Servo motor is in forward direction keeping the sensor straight and the Robot also moves towards Forward direction all -the while calculating the distance of obstacle in forward direction. The loop continues..... - -*/ #include "mbed.h" #include "hcsr04.h" -#include "motordriver.h" -#include "TextLCD.h" #include "Servo.h" -int ping (); -void scan(); -void right (void); -void stop (void ); -void straight (void); -void left (void); -Motor A(p22, p6, p5, 1); // pwm, fwd, rev, can brake -Motor B(p21, p7, p8, 1); -HCSR04 usensor(p13,p14); -TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7 -PwmOut servo(p23); // Servo pin 21 +#include "string.h" +#define HIGH 1 +#define LOW 0 + +void forward(); +void backward(); +void right(); +void left(); +void stop(); +void loop(); + +void blueInterrupt(); +void timerInterrupt(); +void bluecheck(); + +int distance; //Variable to store distance from an object +int checkRight; +int checkLeft; +int function=1; //Variable to store function of robot: '1' running or '0' stoped. By +int pos=90; +int flagBlue=0; +int flagTimer=0; + +Ticker timer; + + +int c; + + +Serial pc(USBTX,USBRX); +Serial blue(PTC15,PTC14); +PwmOut servo(D6); + +char send[512],rcv[1000];//Variables + +int main() +{ + + blue.baud(9600); + + while(1) + { + if(!blue.readable()) + { + !blue.gets(rcv,1000); + if(strstr(rcv,"forward")!=NULL) + { + forward(); + } + else if(strstr(rcv,"backward")!=NULL) + { + backward(); + } + else if(strstr(rcv,"right")!=NULL) + { + right(); + } + else if(strstr(rcv,"left")!=NULL) + { + left(); + } + } + else + { + stop(); + } +} +} + +void forward(){ + + + + pc.printf("fwd"); + + DigitalOut(D3,1); + + DigitalOut(D5, 0); + + DigitalOut(D10, 1); + + DigitalOut(D11, 0); + +} + +void backward(){ + + DigitalOut(D3,0); + + DigitalOut(D5, 1); + + DigitalOut(D10, 0); + + DigitalOut(D11, 1); + +} + + +void right() + + +{ + + + DigitalOut(D3,0); + + DigitalOut(D5, 1); + + DigitalOut(D10, 1); + + DigitalOut(D11, 0); + + + } + + + void left() + + +{ + + DigitalOut(D3,1); + + DigitalOut(D5, 0); + + DigitalOut(D10, 0); + + DigitalOut(D11, 1); + + + } + + + + void stop() + + +{ -unsigned int dist; -DigitalOut myled(LED1); -DigitalOut myled1(LED2); -DigitalOut myled2(LED3); -int count = 0; + DigitalOut(D3,0); -int main () - { - - while (1) // continuos loop to perform the scanning function of HCSR04 .. - //a trigger pulse of Ultrasonic waves having duration 10 nS is sent through the echo pin - { + DigitalOut(D5, 0); - servo.period(0.020); - int distance = ping(); // ping function - straight(); // use the ping() function to see if anything is ahead. - - - if (distance < 10) // the condition for stopping the Obstacle Avoider... - // ...whenever the defined proximity to obstacle is reached. - { - stop(); - scan(); - - - /*switch (a) // switch case for initial testing of the Obstacle detection by sensor and - // Corresponding L.E.D. of the best direction will glow. - - { - case 'r': - myled=1; - break; - case 'l': - myled1=1; - break; - case 'f': - myled2=1; - break; - }*/ - - } - } + DigitalOut(D10,0); + + DigitalOut(D11, 0); + + } - - // A functon to perform the continuos pinging function of HCSR04 .. - //a trigger pulse of Ultrasonic waves having duration 10 nS is sent through the echo pin - - int ping() // ultrasonic sensor is started and data collected is displayed on the LCD - // ping function returns an int value of distance scanned - { - usensor.start(); - wait_ms(200); - dist=usensor.get_dist_cm(); - lcd.cls(); - lcd.locate(0,0); - if (dist <50) - lcd.printf("cm:%ld",dist ); - else - lcd.printf("no object"); - return (dist); - - } + + /* + void loop() + + { + servo.period(0.020); + usensor.start(); + wait_ms(500); + distance = usensor.get_dist_cm(); //Tip: Use 'CM' for centimeters or 'INC' for inches + pc.printf("Dist: %d ",distance); - void scan () - { - - int leftscanval, rightscanval; // variables for storing distance scan values... - //... of nearest obstacle in the left and right direction - - - // Scanning RIGHT side; turning the servo attached to HCSR04 right to check for obstacle distance - - // 0.0016 corresponds to the neutral position of servo motor - // 0.0027 corresponds to the rightmost position of the servo motor - // 0.0009 corresponds to the leftmost position of the servomotor - - for(float offset=0.0016; offset<=0.0027; offset+=0.0001) // turning RIGHT - - { - servo.pulsewidth(offset); // servo position determined by a pulsewidth between 1-2ms - wait(0.10); - } - wait (2); // stopping at RIGHTMOST position for 2 seconds - rightscanval = ping(); // putting the distance of right direction's obstacle in ''rightscanval variable'' - - - - for(float offset=0.0027; offset>=0.0016; offset+=-0.0001) // turning back to the CENTER position - - { - servo.pulsewidth(offset); // servo position determined by a pulsewidth between 1-2ms - wait(0.10); - } - wait(2); // stopping at CENTERMOST position for 2 seconds + //Check for objects... + if (distance > 50){ + pc.printf(" No Object \n"); + forward(); //All clear, move forward! + //noTone(buzzer); + // digitalOut LED(0); + } + else if (distance <=50){ + pc.printf("Halt - Object on the Way \n"); + stop(); + + + for(float offset=0.0016; offset<=0.0020; offset+=0.0001) // turning RIGHT + +{ + + pc.printf("Turning Right"); + +servo.pulsewidth(offset); // servo position determined by a pulsewidth between + +wait_ms(0.10); + +} + +wait_ms(200); // stopping at RIGHTMOST position for 2 seconds + + + usensor.start(); + + wait_ms(500); + + checkRight = usensor.get_dist_cm(); //Take distance from the left side + + pc.printf("DistL: %d ",checkRight); + + + for (float offset=0.0020; offset>=0.0016;) // turning back to theCENTER position +{ + pc.printf("Turning Center"); + +servo.pulsewidth(offset); // servo position determined by a pulsewidth between +offset=offset-0.0001; + +wait_ms(0.10); + +} + +wait_ms(200); + + +for (float offset=0.0016; offset>=0.0012; offset=offset-0.0001) // Turning towards LEFT + +{ + + pc.printf("Turning Left"); +servo.pulsewidth(offset); // servo position determined by a pulsewidth between + +wait_ms(0.10); + +} + +wait_ms(200); // stopping at LEFTMOST position for 2 + + + usensor.start(); + + wait_ms(500); + + checkLeft= usensor.get_dist_cm(); + + pc.printf("DistR: %d ",checkLeft); + + +for(float offset=0.0012; offset<=0.0016; offset=offset+0.0001) + +{ + pc.printf("Turning Center"); + +servo.pulsewidth(offset); // servo position determined by a pulsewidth between + +wait_ms(0.10); + +} + + + //Finally, take the right decision, turn left or right? + + if (checkLeft < checkRight){ + + backward(); + wait_ms(1000); + + + left(); +pc.printf("goingleft"); + wait_ms(400); + + // wait_ms, change value if necessary to make robot turn. + forward(); + pc.printf("now going straight"); + } + + else if (checkLeft > checkRight){ + + backward(); + wait_ms(1000); + + right(); - // Scanning LEFT side; turning the servo attached to HCSR04 right to check for obstacle distance - - - for(float offset=0.0016; offset>=0.0009; offset-=0.0001) // Turning towards LEFT - - { - servo.pulsewidth(offset); // servo position determined by a pulsewidth between 1-2ms - wait(0.10); - } - wait(2); // stopping at LEFTMOST position for 2 seconds - leftscanval = ping(); // putting the distance of right direction's obstacle in ''leftscanval variable'' - - - for(float offset=0.0009; offset<=0.0016; offset+=0.0001) - - { - servo.pulsewidth(offset); // servo position determined by a pulsewidth between 1-2ms - wait(0.10); - } - /*center scan servo (for changing the default position of Servo to the Centre Position ) This method didnt work - though. There is a library of Servo - */ - //servo.pulsewidth(0.00017); - - - /* Comparisons to choose the most appropiate direction for the turning of Robot. Based on the distances stored in variables "leftscanvalue" and "rightscanvalue" */ - - if (leftscanval>rightscanval ) - - { - left(); - } - - else if (rightscanval>leftscanval ) - - { - right(); - } - - else - { - left(); - } - - //return choice; - } - - void stop () // function for stopping the DC motors - - { - A.speed(0); - B.speed(0); - } - - - void left() // function for moving the RIGHT motor in FORWARD direction and LEFT motor in REVERSE direction so... - // ..that the robot turns to the LEFT - - { - for (float s= -1.0; s < 0.0 ; s += 0.01) - { - A.speed(-1); - B.speed(-1); - wait(0.02); - } - } - - - void right () // function for moving the RIGHT motor in REVERSE direction and LEFT motor in FORWARD direction so... - // ..that the robot turns to the LEFT - - { - for (float s= -1.0; s < 0.0 ; s += 0.01) - { - A.speed(1); - B.speed(1); - wait(0.02); - } + + wait_ms(400); + forward(); + // wait_ms, change value if necessary to make robot turn. + } + else if (checkLeft <=10 && checkRight <=10){ - void straight () // function for moving the RIGHT motor in FORWARD direction and LEFT motor in REVERSE direction so... - // ..that the robot turns to the LEFT + backward(); + wait_ms(1000); //The road is closed... go back and then left ;) - { - //for (float s= -1.0; s < -0.7 ; s += 0.01) - { - A.speed(-1); - B.speed(1); - wait(0.02); - } - - } \ No newline at end of file + left(); + wait_ms(400); + forward(); + + } + + } +*/ + \ No newline at end of file
diff -r a87600bebf7b -r 43568a9d4323 mbed.bld --- a/mbed.bld Sat May 18 04:39:55 2013 +0000 +++ b/mbed.bld Fri Mar 24 01:02:04 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/7e6c9f46b3bd \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3 \ No newline at end of file