Introduction: Walter the Sonar Bot
We will program Walter's Sonar
This a video tutorial following the instructable steps.
We will modify the Walter microbot code so we can have a working sonar.
Open the inputs tab and select On Button Press command which I have highlighted.
We will need 2 of these commands, make sure to change one of the buttons to B and leave the other on A.
Open the variables tab and click on make a variable
When you click on make a variable it will ask you to name it to make things simple just name it Button and then press ok, then you should see 3 commands appear.
Drag the Set Button command to On Button command like I showed.
Open the logic tab and grab the command that I highlighted.
Replace the Button Command with the new command.
Select the button variable and replace the first 0. It might take you a couple of tries to get it to snap to the right stop.
Open the variable tab and we will be making a new variable named Sonar.
Go to extensions and search for sonar and choose the one i highlighted.
Grab the set Sonar command and drag it under the if statement.
Drag the Sonar command into the sonar variable.
Next we will change the variables in the sonar command.
Open logic tab and drag the if else command under the Sonar command.
Open logic tab and drag the <0=0> command to replace the true statement.
Drag the Sonar Variable and replace the true statment.
Drag the continuous servo command under the second if statement.
Click on advanced and then open the control tab. Then drag it under the first 2 continuous servo commands.
Drag the second set of continuous command under the wait command.
Add a wait time under the second set of continuous servo command. Then drag the third set of continuous commands under the first else command.
Delete the other statements and leave the else if statement and the stop servo commands.
Drag the stop servo command under the else if statement.
Open the logic tab and drag a <0=0> command to the slot.
Drag a button variable to replace the 0
Now were going to change some of the variables.
This is what the finished code should look like.