Tech issues with combining line and ultrasonic sensors in one sketch


#1

I’ve been trying to combine the two sensors in one Sketch and have used a variety of different approaches for this, including defining sets of instructions as new blocks, running both sets of instructions simultaneously, using an IF ELSE statement for whether the line sensor detects a line or else use ultrasonic sensor instructions… but none of them have worked.

I have e-mailed tech support but so far nothing they have sent has allowed me to fully resolve the issue, however I have made some progress to the point where I can now have the robot follow a line and also turn away from an obstacle, however the line sensor does not function correctly and will lose the line if there is a turn, despite the blocks for this always working when I run this as a separate sketch.

I have attached a screenshot of my latest attempt that partially worked. Any suggestions would be appreciated. Please ignore the Chinese annotations and some of the random variables being set - this was the sketch that I received from mBlock tech support and I have been deleting a lot of things and changing various parts based on my needs, but I didn’t want to delete those elements incase it effected what I was doing.

Thanks.