This give an error SerialEvent.cpp:5: erro: invalid conversion from ‘const char*’ to ‘char’
If using this it's ok
int test = 1;
void setup() {
Serial.begin(9600);
}
void loop()
{
serialEvent(&test);
}
void serialEvent(int *Value)
{
Serial.println(*Value);
}
Why diferent data types is not working?
In serialEvent function is expecting a pointer and I'm passing is address to point on serialEvent(&test) is this the right way of using pointers?
In your first example, test is already a pointer, so referencing it's address isn't doing what you think it's doing. Any array declaration (strings are just null terminated char arrays) returns a pointer to first element in that array. So when you pass &value in the first example, you are telling it to pass the address of the pointer to your array to the function.
As an example, consider the following declaration:
char myString[] = "Hello";
char * myStringPointer;
int myInt = 25;
int * myIntPointer;
To set the pointers equal to the appropriate values, you would do the following:
Every day pass more I love this forum.Your answer is right it is now working fine.This is a big step to me to try myself learn more about pointers.I believe they are very powerful so I'm decided to learn all about them.Sometimes its not easy to filter the information on the web about them.
Anyway I will close this lesson in my brain and move to the next test sketch using pointers.
Thanks for all answers It really help me