Walter the Sonar Bot

by Aidan-Corrales in Circuits > Robots

390 Views, 1 Favorites, 0 Comments

Walter the Sonar Bot

7.png

We will program Walter's Sonar

This a video tutorial following the instructable steps.

1.png

We will modify the Walter microbot code so we can have a working sonar.

2.png

Open the inputs tab and select On Button Press command which I have highlighted.

3.png
4.png
5.png

We will need 2 of these commands, make sure to change one of the buttons to B and leave the other on A.

6.png

Open the variables tab and click on make a variable

6.png
6.png
6.png

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.

6.png
6.png

Drag the Set Button command to On Button command like I showed.

6.png

Open the logic tab and grab the command that I highlighted.

6.png
6.png

Replace the Button Command with the new command.

6.png
6.png
6.png

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.

6.png
6.png
6.png

Open the variable tab and we will be making a new variable named Sonar.

6.png
6.png
6.png

Go to extensions and search for sonar and choose the one i highlighted.

6.png
6.png

Grab the set Sonar command and drag it under the if statement.

6.png
6.png
6.png

Drag the Sonar command into the sonar variable.

6.png
6.png
6.png
6.png

Next we will change the variables in the sonar command.

6.png
6.png

Open logic tab and drag the if else command under the Sonar command.

6.png
6.png
6.png

Open logic tab and drag the <0=0> command to replace the true statement.

6.png
6.png
6.png

Drag the Sonar Variable and replace the true statment.

6.png
6.png

Drag the continuous servo command under the second if statement.

6.png
6.png
6.png
6.png

Click on advanced and then open the control tab. Then drag it under the first 2 continuous servo commands.

6.png
6.png
6.png

Drag the second set of continuous command under the wait command.

6.png
6.png
6.png

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.

6.png
6.png
6.png
6.png

Delete the other statements and leave the else if statement and the stop servo commands.

6.png

Drag the stop servo command under the else if statement.

6.png
6.png

Open the logic tab and drag a <0=0> command to the slot.

6.png
6.png

Drag a button variable to replace the 0

6.png
6.png
6.png
6.png

Now were going to change some of the variables.

2.png

This is what the finished code should look like.

Step 20: Here Are Video Instructions If You Prefer That! :)

Walter- Sonar Programming tutorial