Question serial.print

Hi,

For a project i have to send "A0" (The letter and the number) from a Master using TX/RX and receive it on the slave and use the value in a switch case like

switch(value){ case A0;

//do something break; }

On the slave with the terminal i receive A0 (thats ok) but i'm not able to use it in the switch case.

Thanks for your help!

I believe A0 is 14, to be sure, try: Serial.print(A0);

Without seeing your code it is impossible to say what the problem is.

Have a look at serial input basics.

...R

Master :

void loop(){

Serial.print(C12); }

Slave :

void loop(){

while(Serial.available()>0){ int value = Serial.read();

switch(value){

case 'C12':

//do something break; }

Thanks!

All the code, please. Use code tags

case 'C12':

Single quotes for a single character. You can't jam 3 characters into there. For three characters you need a string, and then you can't use switch / case.

Also, Serial.read() reads one character. If you want three characters, you'll have to call it three times and combine them in an array or in three different variables.

Serial.print(C12);

Do you have a variable C12 somewhere in the code?

If not, then this is going to give you a not declared in this scope error.

If you want to send the three characters C and 1 and 2, then you need to use a string.

Serial.print("C12");