arduino sketch for making audio sound module work

hey guys,

Can you guys take a look at the sketch I wrote for the arduino + sparkfun’s audio sound module([http://www.sparkfun.com/products/9534

)? Basically since the module plays files named 0x0001 to 0x0500, I am making a sketch that takes 3 numbers that tell the module which file to play. First I concatenate those 3 numbers as decimals since 0’s on the left can be ignored once I convert to hex. Then I sprintf it hex. I’m not quite sure if my syntax is right or if this is the right approach. I based my code largely off

[<LINK_TEXT text=“http://yapan.googlecode.com/svn/trunk/a … D_Test.pde”>http://yapan.googlecode.com/svn/trunk/arduino/examples/SOMO_14D_Test/SOMO_14D_Test.pde</LINK_TEXT>

int total=0;
char buf[8]={0};
const int clockPin = 2;  // the pin number of the clock pin
const int dataPin = 3;  // the pin number of the data pin
const int busyPin = 4;  // the pin number of the busy pin
const int resetPin = 5;  // the pin number of the reset pin


const unsigned int VOLUME_7 = 0xFFF7;
const unsigned int STOP = 0xFFFF;

void setup(){

 Serial.begin(9600);
	pinMode(clockPin, OUTPUT);
  	pinMode(dataPin, OUTPUT);
        pinMode(busyPin, INPUT);
  	pinMode(resetPin, OUTPUT);
        digitalWrite(clockPin, HIGH);
  	digitalWrite(dataPin, LOW);
// reset the module
        digitalWrite(resetPin, HIGH);
        delay(100);
        digitalWrite(resetPin, LOW);
        delay(10);
        digitalWrite(resetPin, HIGH);
        delay(100);

  sendCommand(VOLUME_7);

}

void loop(){
if (Serial.available() > 0) {
    int moveServo = Serial.read();
    Serial.flush();
 
     if (moveServo =='a'){
		//audio begins, stop haros movement and start looping    
		myservo.write(94);
		//get first 3 bit of incoming data 001-500 for file name
		while(Serial.available()<3){
		}
		for(int i=0;i<3;i++){
			//gets decimal concat, ignores 0’s on left
			total=total*10+Serial.read();
		}
               sprintf(text, "0x%X", total);
               strtol(text,&total,10)		
               sendCommand(total);
		delay(1000);
		
		
       }


}
void sendCommand(unsigned int command) {
  // start bit
  digitalWrite(clockPin, LOW);
  delay(2);

  // bit15, bit14, ... bit0
  for (unsigned int mask = 0x8000; mask > 0; mask >>= 1) {
    if (command & mask) {
      digitalWrite(dataPin, HIGH);
    }
    else {
      digitalWrite(dataPin, LOW);
    }
    // clock low
    digitalWrite(clockPin, LOW);
    delayMicroseconds(200);

    // clock high
    digitalWrite(clockPin, HIGH);
    delayMicroseconds(200);
  }
  // stop bit
  delay(2);
}

thanks for the help](http://yapan.googlecode.com/svn/trunk/arduino/examples/SOMO_14D_Test/SOMO_14D_Test.pde)](http://www.sparkfun.com/products/9534)