If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content
Current time:0:00Total duration:3:32

Video transcript

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 sensor the technical name is - comet er 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 but we'll pretend this is the zeroth 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 just pretend 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 in to 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 gonna 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 Tacoma to that zero point I mentioned or it can be a reed 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 gonna pass it into a sound block so I'm gonna grab a sound output here and let's say I want to generate a tone I'm gonna change the tone to be a tenth of a second and now I'm gonna wire a value and again if you expand make sure to expand this so 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 this sound block so I'm gonna take my degree reading and a 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 gonna drop it inside a loop to get some dynamic behavior going so I'm gonna go ahead and run this program and let's see it in action