Shopping at LEGO or Amazon?
Please use our links: LEGO.comAmazon
As an Amazon Associate we earn from qualifying purchases.

I have a coding problem in Lego EV3 Mindstorms

I'm having trouble with codes "if then" and "if then else".
My aim is,
  • When the robot sees red it will start the D engine and drop the lego piece.
  • When the robot sees black, it will start the a motor and lower the arm and pick up the load standing on the road.
  • If the robot does not see red and black, it will continue on its way and will stop when it sees the wall.
I have uploaded the coding screenshot.
It isn't working properly.
The robot only does the stopping part when it approaches the wall.
Where am I doing wrong?


  • HuwHuw Administrator Posts: 7,076
    Perhaps try making it event driven rather than in a forever loop

    when program starts
    initialise and start moving

    when 2 is red

    when  2 is black

    when wall is close
    stop moving

Sign In or Register to comment.

Shopping at or Amazon?

Please use our links: Amazon

Recent discussions Categories Privacy Policy

Howdy, Stranger!

It looks like you're new here. Sign in or register to get started. is a participant in the Amazon Services LLC Associates Program, the, Inc. Associates Program and the Amazon EU Associates Programme, which are affiliate advertising programs designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.

As an Amazon Associate we earn from qualifying purchases.