the SoundMachine program
The next program, SoundMachine, turns the TriBot into a simple sound generator. The wheel attached to motor B controls the volume; turn it to make the sound louder or softer. The wheel attached to motor C controls the tone (or pitch); turn it to make the sound higher or lower.
The program uses a Sound block to create the sound and uses two Rotation Sensor blocks to measure how far each wheel has been turned. You’ll use data wires to connect the output from the Rotation Sensor blocks to the Sound block so that the B motor controls the volume and the C motor controls the tone. I’ll present the program in three parts; first you’ll control only the volume, then you’ll add some code to control the tone, and finally you’ll display ...
Get The Art of LEGO MINDSTORMS NXT-G Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.