I've only been trying out arduino for a few days, so im pretty inexperienced. I've been trying to test out a few things with the serial monitor. I've done several little projects and had no syntax problems, so I thought I had a grasp on it, but I'm not so sure now. The main error I'm seeing is the one in the title. "variable or field 'response' declared void" I'm not sure if there is a problem with the function being void, or whether its a problem with the parameters, so I really don't know where to start. If anybody could give me an idea with what I'm doing wrong, that would be greatly appreciated. Thanks!
char initResponse;
char cusResponse;
void setup() {
Serial.begin(9600);
Serial.println("Hello, my name is Arduino");
initResponse = 'Did it';
cusResponse = 'work?';
if Serial.available() > 0)
{
response(initResponse, cusResponse);
}
}
void loop() {
}
void response(initResponse, cusResponse)
{
Serial.print(initResponse);
Serial.println(cusResponse);
}
rfitz123:
Now I really feel clueless, because I still don't know what I'm missing.
When you write a function definition, you don't put in the names of the variables you intend to pass to it. You put in placeholder names for the arguments. If you want to use those two global variables then get everything out of the parenthesis. Global variables are already visible to any function.
Sorry for posting an issue about the same code, but it seems that I've solved one error and made another. Both char's produce the same error. This is the code.