Here are my tips for you: 1. Your program should start with the "Drive forward" block. The part with detecting obstacles and changing colors is correct.
2. After turning right the robot should check if there's any obstacle blocking his way.
When you use the "Repeat" block and the "If there's obstacle" block it means that the robot has to wait for an obstacle to go on.
According to the instructions, the robot has to check this condition only at that one moment sothere's no need to add the "Repeat" block here - you should remove it.
3. If there's an obstacle he should turn 180 degrees and this part is correct.
After that he should check again if there's any obstacleless than 40 cm away from him and if there is, he shouldturn left. Notice that he should check this condition after detecting an obstacle from point 2.
You should place the second "If there's obstacle" block inside the first "If there's obstacle" block.
That will cause the robot to check if there's a second obstacle on his way after detecting the first one.
I hope my tips are understandable. :) I will wait for the screenshot with the changes made!