Using Serial.Print in caller function? Is this even possible?

Is there a way to use the Serial.Print("STUFF") function inside a caller function? Or is it only used in the void loop ( ) statements? Im doing the former and getting an error message.

"Caller function"?

// Tuesday, July 10, 2012 // Check Continuity Function. Please help. Thanks! Code compiles, but nothing prints on serial monitor. I connect pins 6 and 7 together. They're both digital pins.

int Pin6=6; int Pin7=7;

void setup(){ Serial.begin(9600); pinMode( 6,INPUT ); pinMode( 7, OUTPUT ); digitalWrite( 7, HIGH); }

void loop() { Check_Continuity; }

void Check_Continuity() { int val=0; val= digitalRead(Pin6); // read input pin6 Serial.print(val); if (val==HIGH) { Serial.print("Continuity Check Passed"); } if (val==LOW) { Serial.print("Continuity Check Failed"); } }

It should print out the value read, at least.

If you don't get that I suggest you create a 'hello world' sketch that does nothing but print a message on the serial port. If you don't have serial output then anything else is going to be problematic.

Are you sure your sketch has actually loaded OK? Have you successfully loaded other sketches on this Arduino and seen them run?

Once you get serial output working, you probably want to combine those 'if HIGH' and 'if LOW' conditions into a single if-else statement.

You have a wire in between 6 and 7 right?

void loop() {
   Check_Continuity(); 
}

Read this before posting a programming question

Your code? Your error message?

You will certainly get an error with Serial.Print("STUFF").
It’s Serial.print("STUFF")

JavaMan:
Serial.print(“STUFF”);

Perhaps the original question is related to the syntax error in this post:
http://arduino.cc/forum/index.php/topic,113750.0.html

Good call, James. Check the times on the OP's, less than 12 minutes apart.

That flushing sound is the post I had made going down the tubes.

Perhaps the original question is related to the syntax error in this post:

I'm not sure it's a syntax error, but evaluating a function pointer and ignoring the result.

Topics merged - there didn't seem much point in wasting peoples' time answering the same question in two threads.

I fixed the code a bit, and not it looks like this:

// Tuesday, July 10, 2012
// Check Continuity Function 

int Pin6=6; 
int Pin7=7; 

void setup(){
  Serial.begin(9600);
  pinMode( 6,INPUT );
  pinMode( 7, OUTPUT );
  digitalWrite( 7, HIGH);
}

void loop() {
// Check_Continuity; 
// Serial.print("Hello World"); IT WORKS!! 

//}

// void Check_Continuity() { // IT WORKS!! 
    int val=0;
    val= digitalRead(Pin6); // read input pin6
        Serial.print(val); 
    if (val==HIGH) {
        Serial.print("Continuity Check Passed"); 
        Serial.print("\n"); 
    } 
    if (val==LOW) { 
        Serial.print("Continuity Check Failed"); 
        Serial.print("\n"); 
    } 
}

Moderator edit: code tags added.

The problem is when I call the function, the code no longer works to check continuity. This check continuity only prints to the serial monitor, so it's a void function. Am I calling the function correctly in the void loop()?

Clown_of_God:
Am I calling the function correctly in the void loop()?

No, as pointed out already it should be:

void loop() {
Check_Continuity();
}

Clown_of_God: I fixed the code a bit, and not it looks like this:

// Tuesday, July 10, 2012
// Check Continuity Function 

int Pin6=6; int Pin7=7;

void setup(){  Serial.begin(9600);  pinMode( 6,INPUT );  pinMode( 7, OUTPUT );  digitalWrite( 7, HIGH); }

void loop() { // Check_Continuity; // Serial.print("Hello World"); IT WORKS!!

//}

// void Check_Continuity() { // IT WORKS!! int val=0; val= digitalRead(Pin6); // read input pin6        Serial.print(val); if (val==HIGH) {        Serial.print("Continuity Check Passed");        Serial.print("\n"); } if (val==LOW) {        Serial.print("Continuity Check Failed");        Serial.print("\n"); } }



Moderator edit: code tags added.

The problem is when I call the function, the code no longer works to check continuity. This check continuity only prints to the serial monitor, so it's a void function. Am I calling the function correctly in the void loop()?

You have some code in loop() and some comments. You don't have a continuity check function and you don't call it. You have code in loop() that checks pin 6 and if it doesn't work then check your wiring. If that doesn't do it then maybe get your eyes checked.

Everything works now. Thanks, everyone!