Problem related to coding

#include <SPI.h>

const int slaveSelect = 11;

void setup()
{
Serial.begin(9600);
SPI.begin();
SPI.setDataMode (SPI_MODE0); //Mode 0: CPOL=0, CPHA=0 / (0,0)
pinMode(slaveSelect, OUTPUT);
ADC_Set(0,0);
}

void loop()
{
for(unsigned int i = 0; i < 41; i++) // 0.1V Schritte bis 4.000V (16004062.5E-6 = 4.000V)
{
ADC_Set(1600,i); // 0.1V
delay(300000); // 5 Minuten
}
}

void ADC_Set(unsigned int Wert, unsigned int Faktor)
{
if (( Faktor < 4100) && ( Faktor >= 0))
{
MSB = highByte(WertFaktor);
LSB = lowByte(Wert
Faktor);
digitalWrite(slaveSelect,LOW); // Slave waehlen
SPI.transfer(MSB); // MSB
SPI.transfer(LSB); // LSB
digitalWrite(slaveSelect,HIGH); // Slave deaktivieren
delay(10);
}
else
{
Faktor = 0;
}
}

I tried this code but it shows MSB was not declared in the scope. What changes should be made to make it correct?

And what line number did it give with the message???

Paul

I do not see where the variables MSB or LSB are declared.

This will declare local variables. MSB or LSB will not be accesable outside the if block.

    byte MSB = highByte(Wert*Faktor);
    byte LSB = lowByte(Wert*Faktor);

Information on variable declaration.

Variable scope.