Combining ultrasonic and line follower codes


#1

Hi

I have a problem combining the codes for ultrasonic sensor and line follower sensor. When I uploaded the combined codes, the line follower works well. However, the ultrasonic sensor does not seem to be responding as it is supposed to. but when the bluetooth module is used, the line follower will be the one that does not work as desired.

Any help is greatly appreciated. Thanks.


#2

@Raihanah_Hussin,

Could you upload a copy of your code so some of can take a look at it. Use the upload button in the reply area.

Thanks,

Mike


#3

Hi @mddickey

here you go

Thanks a lot


#4

Hi have you figured out the code


#5

I am able to get both codes to run together. However with an added device program fails. I have a line follower program connected to a ultrasonic sensor and it works perfectly. However, when adding a servo the mbot seems to ignore the ultrasonic coding and skips to the servo.


#6

Try this technique
Doing two or more things at once
Note I called this Multitasking.
The Arduino is a single thread CPU so we are actually Multithreading, sort of.


#7

Hi all,

can anyone help me out with mBlock program.

I am using the same program from Decision narrow line Chapter 14 for line following and obstacle avoidance for my mBot Ranger.

http://122.228.233.142/download.makeblock.com/ranger/tutorials/Chapter%2014%20Decision.pdf?wsiphost=local

How ever, the program looks like the ranger stops once it detect the
obstacle and turn around and goes back. (Please see the attachment for
mBlock program)

Can anyone help me to do the same procedure as in the http://openlab.makeblock.com/topic/56e38e5660a70d5c503f7fce1
where, mBot should be replaced by mBot Ranger.

Please help me to fix the obstacle avoiding algorithm moving forward for the program attached.


There, the logic is confusing under the ultrasonic sensor algorithm, i tried to change as below

if distance >15,
run right 100rpm
wait 0.1sec
runleft 100rpm.

Still the robot goes a turn and goes on the path which it comes from.

It is not taking turn and bypassing the obstacle and not going forward.

Please help me out with the logic.


#8