Using the Romi32U4 library, I programmed the Pololu Romi to play and dance to the Hokey Pokey song.


#include <Romi32U4.h>

Romi32U4Motors motors;
Romi32U4ButtonA buttonA;
Romi32U4LCD lcd;
PololuBuzzer buzzer;

//Music notes transcribed from sheet music found here: https://www.makingmusicfun.net/pdf/sheet_music/hokey_pokey_leadsheet.pdf
const char you_put_your_right_foot_in[] PROGMEM = "MS d8 e8 d8 g4 g4 g8";
const char you_take_your_right_foot_out[] PROGMEM = "MS d8 e8 d8 g4 g4 g8";
const char and_you_shake_it_all_about[] PROGMEM = "MS e8 d8 f#8 e#8 f#8 e8 f#4 R8";
const char you_do_the_hokey_pokey_and[] PROGMEM = "MS d8 f#8 e#8 f#8 e8 f#8 f#8 e8";
const char you_turn_yourself_around[] PROGMEM = "MS d8 f#8 e#8 f#8 e8 f#4 R4";
const char thats_what_its_all_about[] PROGMEM = "MS d8 d4 d8 e4 f#4 g4 R4 R2";

void setup() { //Setup code to display battery voltage was taken from 98-012 Square Lab base code
uint16_t batteryLevel;
  while (!buttonA.isPressed()) {
    batteryLevel = readBatteryMillivolts();

    lcd.clear();
    lcd.print("B=");
    lcd.print(batteryLevel);
    lcd.print("mV");
    lcd.gotoXY(0, 1);
    lcd.print("Press A");

    delay(100);
  }
  lcd.clear();

  delay(500);
}

void loop() {
  ledYellow(1);
  delay(500);
  ledYellow(0);
  delay(500);

  buzzer.playFromProgramSpace(you_put_your_right_foot_in);
  motors.setRightSpeed(100); delay(300);
  motors.setRightSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(you_take_your_right_foot_out);
  motors.setRightSpeed(-100); delay(600);
  motors.setRightSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(you_put_your_right_foot_in);
  motors.setRightSpeed(100); delay(600);
  motors.setRightSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(and_you_shake_it_all_about);
  while(buzzer.isPlaying()){
    motors.setRightSpeed(100); delay(50);
    motors.setRightSpeed(-100); delay(50);
  }

  buzzer.playFromProgramSpace(you_do_the_hokey_pokey_and);
  motors.setRightSpeed(-100); delay(200);
  while(buzzer.isPlaying()){
    motors.setRightSpeed(100);
    motors.setLeftSpeed(-100); delay(100);
    motors.setRightSpeed(-100);
    motors.setLeftSpeed(100); delay(100);
  }

  buzzer.playFromProgramSpace(you_turn_yourself_around);
  motors.setRightSpeed(100);
  motors.setLeftSpeed(-100); delay(2000);
  motors.setLeftSpeed(0);
  motors.setRightSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(thats_what_its_all_about);
  motors.setRightSpeed(0);
  motors.setLeftSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(you_put_your_right_foot_in);
  motors.setLeftSpeed(100); delay(300);
  motors.setLeftSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(you_take_your_right_foot_out);
  motors.setLeftSpeed(-100); delay(600);
  motors.setLeftSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(you_put_your_right_foot_in);
  motors.setLeftSpeed(100); delay(600);
  motors.setLeftSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(and_you_shake_it_all_about);
  while(buzzer.isPlaying()){
    motors.setLeftSpeed(100); delay(50);
    motors.setLeftSpeed(-100); delay(50);
  }

  buzzer.playFromProgramSpace(you_do_the_hokey_pokey_and);
  motors.setRightSpeed(-100); delay(200);
  while(buzzer.isPlaying()){
    motors.setLeftSpeed(100);
    motors.setRightSpeed(-100); delay(100);
    motors.setLeftSpeed(-100);
    motors.setRightSpeed(100); delay(100);
  }

  buzzer.playFromProgramSpace(you_turn_yourself_around);
  motors.setLeftSpeed(100);
  motors.setRightSpeed(-100); delay(2000);
  motors.setLeftSpeed(0);
  motors.setRightSpeed(0);
  while(buzzer.isPlaying()){ }

  buzzer.playFromProgramSpace(thats_what_its_all_about);
  motors.setLeftSpeed(0);
  motors.setRightSpeed(0);
  while(buzzer.isPlaying()){ }
}