I am trying to find how to pass a value stored in a variable into a Printin statement.
Is this correct or is there a better way.
int MyValue = 0;
MyValue = 1000;
Serial.println(MyValue);
Also can I use MyValue(2) = 1000. This in attempt to have an array where values could be extracted in a loop. If correct, then how do I declare such an array.
int anArray[4]; //declare an array of 4 ints
void setup()
{
anArray[0] = 10; //assign values to the array - could be done when declared
anArray[1] = 11;
anArray[2] = 12;
anArray[3] = 13;
Serial.begin(115200);
for (int x = 0; x < 4; x++) //read the array values starting at index 0
{
Serial.println(anArray[x]); //print the current value
}
}
void loop()
{
}
Many thanks outsider. I was told earlier my spelling was wrong, being told it was an L but still looked like an I. Will now remember and use that so thanks.
Thanks very much UKHeliBob, exactly what I wanted. And thanks CrossRoads for the extra bit. Not forgetting AWOL.