Speaker sounds

I have been trying to program the vex speaker to “kind of” rev up when the chassis moves. I saw some teams do this with their flywheels last year. I tried making a “for loop” to play different frequencies(used the playTone function) when the joystick moved, but could not find the right frequencies. I have not had much luck and would appreciate any help. Thanks.

If you are wanting to make a pitch depending on the speed of the drivetrain, maybe try something like this:


PlayTone((vexRT[Ch3]*1),5);

What it does is it gives a very accurate tone playing because it changes simultaneously when the joystick moves. You may have to tamper the amount of 1/100 seconds it plays for and the pitch (By changing the *1 to sth like *3)

Thanks, but it did not work. I think it is because, since the value of vexRT(Ch2) keeps changing frequently, it does not play any sound.

Are you sure the speaker is configured correctly? Are you able to play any other sounds? An easy test is that when your cortex shows the yellow blinking lights (waiting to connect with joystick), the speaker should play a simple “doot doot” sound.

Changing the amount of time it plays for makes a difference. Try testing and figuring out how long it should play for. The code was just an example for a rough guess of what you can do :slight_smile:

Yes it plays that sound. I tried other sounds and it also works.

Ok, will try that. I will let you guys know if i get any results.

Keep in mind the value after the comma is the amount it plays for, and each value adds one Centisecond (1/100 a second). Since the tone frequency is measured in HZ, and Your joystick goes from 127 to -127, I would also expect you to change the *1 to something like *5 to make the tone be a bit more sensitive.

I got it to work, but i used the playImmediateTone function. Now I just have to find the right frequency.