Help with newbie code

Here is my code:

#include <SPI.h>

//define output pins

#define DATAOUT 11 //MOSI
#define DATAIN 12 //MISO
#define SPICLOCK 13 //SCK
#define SLAVESELECT 10 //SSB
#define INPUTPIN 2 //Sensor input


byte index1 = 0;
byte index2 = 0;
byte j;
byte Playaddress = B10010110; // 0xA6

void setup()
Serial.begin (9600);  // to see what is happening during run
SPI.begin();  //start SPI
SPI.setBitOrder(MSBFIRST);  // MSB first
SPI.setClockDivider(SPI_CLOCK_DIV4);  // SPI clock is system/4
SPI.setDataMode (SPI_MODE3);  // SPI mode 3

pinMode (DATAIN, INPUT);
digitalWrite (SLAVESELECT, HIGH); //disable device
digitalWrite (SPICLOCK, HIGH); //set clock to high for inactive mode

// SPCR = 01011000
//disables SPI interrupt, enables SPI, MSB first, Arduino is master
//inactive clock is high, rising edge active, 4 Mhz clock
//SPCR =(1<<SPE | 1<<MSTR |1<<CPOL)

byte makesound (index1, index2){  //make sound procedure

  digitalWrite (SLAVESELECT, LOW);  //selects ISD3900
  SPI.transfer (Playaddress);  //sends address for Play command
  SPI.transfer (index1);  //first byte of sound
  SPI.transfer (index2);  //2nd byte of sound
  digitalWrite (SLAVESELECT, HIGH);   //deselects ISD3900

void loop()
 makesound (index1, index2);

I get error messages:
‘index1’ was not declared in this scope
‘index2’ was not declared in this scope
initializer expression list treated as compound expression

There are others but I think that I can figure them out. Any help for this duffer?

byte index1 = 0;

In you loop, you are missing a B (binary) or else you would be passing a fairly large number, and that can't be saved as a byte!

index1= B0001100; index2= B0010011;

Thanks but that does not seem to have changed anything.

Also, the way you got it setup now, INPUTPIN will never go low, nor high, as you defined it as a constant.

I think what you'd want is: if (digitalRead(INPUTPIN)==LOW)

Also, I just tested your code. The error is coming from your function makesound. You didn't define what the inputs where.

Void makesound (byte index1, byte index2){

Edit: I changed makesound to void, as you aren't returning anything anyways. Code compiles on my machine with no errors, although I don't think it will do what you expect it to do. Check over your INPUTPIN. Remember that define replaces all instances of INPUTPIN by 2, so in your Setup code, you are making INPUTPIN == HIGH; will return true, but that isn't changing anything?

It has changed something. Trust us.

When posting code, please use the # icon on the editors toolbar to put the code into a code box. Please go back to your post, click on "modify', highlight the code, click on the # icon, then click on "save".

Also, why bother commenting a binary constant with the hex value which doesn't reflect the binary value?

hmm I tried to compile it getting the same error index1 and index2 look to be declared correctly

I ignored the code doing odd things why doesn't it compile?!?

Post the code again. In code tags.

aha your declaration of makesound should include the types!

byte makesound (byte index1, byte index2)

however why are you a) declaring index1, index2 as global b) initialising them c) passing them as parameters ???

Got it. I put the code into a code box, sorry about that. I will make the mods suggested here and go from there. INPUTPIN will be a hardware switch for test purposes and then a sensor input in the final project.

Thanks for all the help.