i wanted to print 3 integers together in serial monitor bit when i do it get the the error
"no matching function for call to 'HardwareSerial::println(int&, int&, int&)"
You cannot print several integers at the same time using Serial.println()
Print them separately
Serial.print(int1);
Serial.print(int2);
Serial.println(int3);
You could concatenate them together in a string then print that, but why would you do that ?
Which Arduino board are you using ?
i am using arduino uno
i would like to do that cause i am trying to make my a arduino as a game controler so it would send all the switches value in one line and then the python program would read it and emulate those switches
how can we concatenate.....
i am bit new to arduino
Do as @UKHeliBob suggested in Reply #2
My example will do what you describe
What exactly is your Python script expecting ?
- 3 bytes one after the other
- a string containing the ASCII representation of the bytes
- something else ?
If you want to send the raw bytes then Serial.print() won't do because it sends ASCII text, but Serial.write() will. If you put the int values in an array then you can send all 3 of them with a single Serial.write()
So, what exactly do you want ?
well i havent designed the python script yet but my plan is to just take a line then split it so i will follow your solution no 1 to just print all those values seperately
thanks for answers and valueable time
Serial.print and Serial.println place data in a buffer; that buffer is transmitted using interrupts (so you basically don't have to worry about that).
In layman's terms, when using UKHeliBob's example, buffer will contain the two bytes for int1, the two bytes for int2, the two bytes for int3 and a < CR >< LF >. Computers have no grasp of lines, only of data; in python you can probably read till you encounter < CR >< LF > which will indicate the end of a line for humans, for the computer it's (as said) just data.
If you are going to separate the values in Python then you would be wise to send a separator such as a comma between values and a start and end character, perhaps < and >, so that you can keep the two systems in step
However you format the output it is important that you understand the difference between printing 65 as text (2 bytes) and writing 65 as a single byte
i will keep that in mind
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.