Line follower sensor+ color sensor no working when codes combined


#1

Hi,
I have been trying to do a simple code where a colour sensor will detect a start colour (green) to activate to the mbot to start moving using the line sensor and stop when it detects a red colour. Separately everything works. The line follower works on its own. The colour sensor detects colour correctly. The problem is when i combine the codes using conditionals if then else. The colour detects and starts the motors and mbot moves but the line following codes fail and the mbot goes off track. Anybody can help point out my mistake?


#2

Hi seal6,

Sorry for my English and not being able to send the solution in version 3.0 of mBot because I have version 5.0 and I don’t have the color sensor. Finally, I would have liked to see your journey but I still have a good idea in mind.

The problem is your first IF because once you leave with your green color, the mBot no longer fits your function: linedetector2. The reason is that your mBot is on black or white and no longer on green.
ici

Solution:

  1. Loop by checking your green color and start your mBot
  2. Loop by checking your 4 other conditions but not your green color: Black / Black, White / Right, White / Left and Red.

Solution in version 5

P.-S. I haven’t verified the solution but the concept should be there.


#3

Here is your first loop, it might look. Maybe there is no Wait until in your version 3 of mBlock?
2020-12-05%2011_35_22-mBlock%20Block-Based%20IDE-%20Coding%20for%20Beginners


#4

Hi Crackle,
Thanks for the quick reply. Will test it out in the morning :slight_smile:

Seal6


#5

Thanks for your help so far. I managed to get some stuff working but this line sensor is really suspect. Codes that worked last night suddenly couldnt this morning. Spent whole day testing and retesting troubleshooting the weird outcomes of the various flags i placed in the code. To such extent i suspect the board and line i was provided was too reflective giving weird readouts to the line sensor IR that i painted my own test track using matt acrylic. Even then it was touch and go results until surprisingly evening came and all started to work ok :roll_eyes::expressionless: Seems impossible daylight messing about with the IR sensors but i have experienced many weird technical gremlins before to dismiss such thoughts. Thankful to the Gods of Tech for the reprieve and rushed some quick tests and code runs so that at least some basic operations seem to come together.One small step forward but expect many more SNAFUs.Just too many x-files points of failure for my liking 🥴:expressionless::thinking:.still ongoing test. Autonomous Logistic Bot Proof of Concept

Autonomous Logistic Bot Proof of Concept test bravo

Sorry i didnt use procedure blocks as failures seem to occur when i use it. Maybe its just my spagetti codes :roll_eyes:. Uploading here because i cant seem to find any mentioned solutions for my similar problem in this forums so maybe the poster problem has been solved but not shared. So i thought i just shared what i have in case it might help others. Please excuse the messy code.

Seal6



#6

Hi phoque6,

I just noticed that your color sensor was another sensor than the one to follow the lines.

Here are my observations

  • Black felt pen (does not work)
  • Black electrical tape (intermitant)
  • Black duck tape (Functional)

I had the same problem but with my black duck tape everything is fine. Otherwise, I saw a light cover to put above the sensor in a video.

In the end, it’s all about reflection.

Michel


#7

Thanks Michel ! Learn something new everyday

Cheers,
Seal6


#8

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.