Skip to main content

Posts

Showing posts with the label vex robot

VR robot in a maze - from Blocks to Python

Recently I produced a post about playing with Vex Robotics VexCode VR blocks and the Maze Playground. The post finished with me saying I would like to play with Python and do a Python version of it. Well it is actually very easy to do it. You can do it in two stages from the block code. First click on the <> icon (lighted in the figure above and it gives a further view producing Python code that changes as you change the blocks. The last stage is to convert to a text project (button at the bottom right of the screen. Example of the code. myVariable = 0 def when_started1(): global myVariable drivetrain . drive_for ( FORWARD , 100 , MM ) while not down_eye . detect ( RED ): drivetrain . drive_for ( FORWARD , 5 , MM ) if right_bumper . pressed (): drivetrain . drive_for ( REVERSE , 30 , MM ) drivetrain . turn_for ( LEFT , 20 , DEGREES ) drivetrain . drive_for ( FORWARD , 20 , MM ) else : if l...