Familiarize yourself with rotation sensor. Build a volume knob. Created by Brit Cruise.
Want to join the conversation?
- How does a tachometer differ from other sensors that measure rotation or angle, such as a potentiometer or rotary encoder?(2 votes)
- Can you build a car out of legod(0 votes)
It's important to remember that the motor can do much more than simply drive wheels on a vehicle. And that is because it's equipped with an internal rotation censor. The technical name is tachometer. And what it does is, at any time it stores a number which represents the rotational position of the motor in degrees. So for example, let's say we wanted to create a volume knob, so we stuck a beam on our motor. At this point, the tachometer may read zero, let's say. We'll pretend this is the zero position. And as we rotate our motor, this number will update in real time to tell us the position of the motor. So if we couldn't even see the motor, we could just be looking at this number and we could understand where the motor is. And if we rotated it back here, again, it would update to zero. And if we rotated it all the way around, the tachometer would read 360. Now this is very cool, because ignoring the whole motor-- let's pretend we're the robot and we only have access to this number. Let's say this number is x, and x will range between 0 and 360, depending on the position of the motor. Now we could do something with this value, whatever x is, such as we could wire it into a sound block so that the sound block will change its volume depending on the position of the motor. So let's do this simple warm-up example. First, I'm going to plug in a motor to Port C on my block. And now I'm going to grab my rotation sensor, which is under the input, of course. And I will select the rotation sensor so the settings come up. First I'm going to assign it to Port C. And there's two things you can do with a rotation sensor block. You can either set it to reset, meaning when my program hit this block, it would reset the tachometer to that zero point I mentioned. Or it can be a read block, meaning I want to read a value from the motor and do something with it. In this case, I want to read the value. And I'm going to pass it into a sound block. So I'm going to grab a sound output here. And let's say I want to generate a tone. I'm going to change the tone to be a tenth of a second. And now I'm going to wire a value in again. If you make sure to expand this, it will go all the way down to the bottom. Read the degree reading from the rotation sensor. And we want to feed it into the volume input on the sound block. So I'm going to take my degree reading, going to click, click again, and connect them. And now we have a sound block which is getting its volume from the rotational reading on a motor. And before I run this I'm going to drop it inside a loop to get some dynamic behavior going. So I'm going to go ahead and run this program, and let's see it in action. [TONE SOUNDS]