With the mBlock IDE, you’d need to tether the robot via WiFi, Bluetooth, or possibly the USB cable (haven’t tried that one because OS X El Capitan screwed up the USB stack and I haven’t gotten it to work with the mBot board), and run the program from the mBlock IDE. See the thread at http://forum.makeblock.cc/t/changing-notes-on-the-speaker/2153/2.
If you’re trying to do it from the Arduino IDE, you’ll need to get the current Makeblock libraries and set the tone with the MeBuzzer::tone methods:
// frequency (in hertz) and duration (in milliseconds).
void MeBuzzer::tone(int pin, uint16_t frequency, uint32_t duration)
{
buzzer_pin = pin;
int period = 1000000L / frequency;
int pulse = period / 2;
for (long i = 0; i < duration * 1000L; i += period)
{
digitalWrite(buzzer_pin, HIGH);
delayMicroseconds(pulse);
digitalWrite(buzzer_pin, LOW);
delayMicroseconds(pulse);
}
}
// frequency (in hertz) and duration (in milliseconds).
void MeBuzzer::tone(uint16_t frequency, uint32_t duration)
{
int period = 1000000L / frequency;
int pulse = period / 2;
for (long i = 0; i < duration * 1000L; i += period)
{
digitalWrite(buzzer_pin, HIGH);
delayMicroseconds(pulse);
digitalWrite(buzzer_pin, LOW);
delayMicroseconds(pulse);
}
}
void MeBuzzer::noTone(int pin)
{
buzzer_pin = pin;
digitalWrite(buzzer_pin, LOW);
}
Hope this helps.