Modkit Self-Driving Car Red Light Green Light


#1

I’m having my student work on a self-driving car project and he is working on a program that allows his car to detect red lights for stopping and green lights for moving forward. This is the code we tried at first and it did not work. When downloading the program to the robot, it mentioned an error concerning the “stop” command. If we change the “stop” to a “drive REV 1 mm”, it goes reverse 1 mm as it should. We’re not sure why it’s not stopping when the color sensor detects a red light. Any ideas?

6e73941f8dce6562bc084a0541c92582.jpg


#2

Would seem to me that it might work if you grouped the commands into one loop. See attached suggestion.

It would help if you could list the exact error message.

ce42fb4f9a6d0ce019d33e5e7dd23a64.png


#3

It says “Error message: reference to ‘stop’ is ambiguous” for my code and your code.


#4

Stop is most likely a reserved word in Modkit, its the software’s way of saying you can’t use it.


#5

“stop” is actually one of the Modkit elements that can be dragged into the screen.


#6

Apologies, I thought you meant you had used a broadcast or variable somewhere called stop.

@cmendoza Can you upload the actual Modkit file, it will be easier to diagnose.


#7

When I go to upload the file to this forum, I get an error saying that it is an invalid file. I don’t think this forum allows the attachment of modkit/mk4v files.


#8

Ironic isn’t it?
You’ll need to put it inside a zip file.


#9

Thanks for the tip.

RedLightGreenLight.mk4v.zip (1.21 KB)


#10

Sorry for the slow reply @cmendoza
The file must have just become corrupt. There is nothing wrong with the program itself and if recreated on a new template, it is absolutely fine. I have no idea how it has happened and I can’t seem to fix it, but the syntax is fine so just recreate it on a blank program.


#11

Thank you.