Some of our other inventions could avoid bumping into things like walls. And some could even turn around and find an new path.
For a robot to be really useful, it has to really find its way around. Think about a self-driving car. It has to do more than avoid running into cars and people. It has to stay inside the road and adjust the steering if it is close to the edge.
Click here to see a video of Walldyn the Dragon in action.
Let's build Walldyn the Dragon, who can find its way around the Lego box or any barrier you put there. Then we'll write a program that gives Walldyn really simple instructions: steer left or steer right. That's enough to get around the box!
The black peg is on the other side between the two axles.
Same on the other side.
There's that black peg.
This new yellow piece goes right under the long axles.
This is Walldyn's tail.
Just place the black axle in the hole for now.
Now the black axle of the tail should be held in place. When the tail wags, it should touch the tan gears on either side.
It can be tricky to get the green L onto the black pegs.
This side of the wheel is on the outside. The flat side is on the inside.
Like this.
Same for the other side!
Plug the sensor and the motor in first. Then put the big block onto the body.
This helps keep the cables out of the way. Be careful not to pinch the cables or fold them.
A dragon needs wings, right?
Let's start with this program. Walldyn won't drive around the Lego box yet, but you'll see how it works first.
Here's what happens. The motor turns on at power = 4. Then the distance sensor sends a message with its reading which is a number from zero to ten - like a letter in the mail.
The other two chains of blocks are waiting to get a message. If it's zero, the top one gets the message and turns the motor in one direction and lights a purple light.
If it's ten, the bottom chain gets the message. It turns the motor the other way and lights an orange light.
The loop on the main chain makes it keep repeating this, over and over.
Try it. You'll have to put something that touches right up to the sensor for it to get a zero.
Walldyn should spin one direction or the other.
Now you see how the messages work.
So what if the sensor reads 1, 2, or 3 ? Something besides 0 or 10?
This program gets fancy, but follow it through with your finger.
The sensor sends its message. All the chains in the middle will get that message, whatever number it is.
Then they send another message: the letter r or the letter l . We know these mean left and right, but it really doesn't matter which letter you use.
The two chains on the right get these messages, r or l . They turn the motor's direction.
So really all Walldyn has to do is turn one way or the other way. It turns away from the box if it is close to the box and the sensor sends a small number. And then Walldyn turns the other way if it is far from the box and the sensor sends a larger number.
Change the program and see what happens!