Arduino output horizontal print to vertical print

Hello I have a problem with the output of an EMG Sensor this is the code that I used

int EMGPin = A1;
int EMGVal = 0;

void setup() {
Serial.begin(115200);
}

void loop() {
EMGVal = analogRead(EMGPin);
Serial.println(EMGVal);
}

the EMG sensor sends out an INT value from 0 to 1023 the problem is its output is continues. when I used CoolTerm to get the data and save it as a TXT file its output is horizontal and is saved as such like this

123123

what I want the output to be is to output it vertically like
1
2
3
1
2
3

I cant find any guides online because I dont know how to ask that specific question.

There may be someone here that is familiar with Coolterm and can help you, but this is an Arduino forum so, no guarantee. Perhaps ask at the Coolterm forum.

What is CoolTerm?
Usually in a .txt file you have some symbol (delimiter) to keep values separate. That delimiter should be set to space ' ', comma ',', ' ; ' , or something else. It is missing in your print...
You might try 'EOL' as delimiter. Then your data wil be in one column...

You can send the individual digits of a number to coolterm and save that to file. That's just a matter of some mathematics.

I will not ask you how you want to separate readings :wink:

Coolterm connects to my arduino and acts as the serial monitor and saves the output as txt file I think cause that's how I understand it.

yes I used Serial.print(","); before the Serial.printIn(EMGVal);
and got the output as 1,2,3,1,2,3

some guides online printed out vertically this is how their codes look like

void setup()
{
     Serial.begin(9600);
}

void loop{}
{
     int sensor1 = analogRead(A0)
     int sensor2 = analogRead(A1)
     Serial.print(sensor1);
     Serial.print(",");
     Serial.printIn(sensor2);
     delay(100);
}

they get an output like
214,212
245,213
277,211

so I'm not sure what to put on the code to have the same output as that

That output prints the values of two analogue inputs on one line. You only read one analogue input, so why would you want that?

its just something like a comparison I want one analogue input to be printed on one line separated by a comma so that I can convert it to a CSV file the problem is it doesn't print the outputs vertically it prints the output continuously so when I convert it on the Excel its output is printed per column in 1 row instead of all the values in 1 column like
312|213|417|213
instead of
312
213
417
213

In your code it says Serial.printin().
Should that be Serial.println()? (Subtle difference...)
That will put the next value on a new line...

I edited the Serial.printin() sorry it was just a mistype on my part they are all Serial.printIn() no more lower case i

Post your revised code (in a new post).

For a single input, there is no need for comma separated values.

I did not revise any of my code what I revised was my answer to build_1971 where I typed the guides I found online that printed it properly

as for the no need comma for the separated values I did not add the

Serial.print(",");

to my question so it does not have any comma that separate the value

It is a small L (l) not a big i (I).
It stands for printline. It prints what is in between () and then it prints a '\n'. So it will move to the next line.

oh my bad I thought it was capital i not lower case L it shows an Error if I use capital i
but yes it still prints it continuously maybe it has something to do with the EMG sensor itself I will try to read up more on the sensor this is what I bought
Muscle Signal Sensor EMG Sensor Controller Set Kit Detects Muscle Contraction Activity For Arduino Microcontroller Electromyographic Electromyogram | Lazada PH

You do a reading (analogRead); that gives you a number between 0 and 1023 (both included.
You print that (as text). Why do you want e.g. 1023 to be split over 4 lines (as requested in your opening post)? Or why do you want to represent 1023 as 1,0,2,3.

Each line represents a new reading of the sensor. Your (perceived?) problem has nothing to do with your sensor.

If you have 500 cents in your purse and I ask you to write down the number of cents in your purse, do you write

5
0
0

or do your write

5,0,0

or do you write

500

???

You can run the following test. Disconnect the sensor, power up the Arduino and open serial monitor. You will get some random numbers.

Next connect A1 to GND; reading should become zero (0).
Next connect A1 to 3.3V; assuming a 5V processor (e.g. Uno), your reading will become around 675.
Next connect A1 to 5V; only do this if your board indeed has a 5V processor. Your reading will become 1023.

simulated output

...
...
0
0
0
675
676
675
674
1022
1023
1023
etc

There will more than likely be a small variation in the numbers.

no sorry if its confusing I did not want to split the values that the analog reads.
in the serial monitor in the arduino it works as intended it prints out a value from 0 to 1023 then moves on to the next line. the problem is with how its being saved by coolterm. it saves a value from the output but does not move on to the next line it just saves it as if typing continuously without pressing enter key to move on to the next line.

maybe I will just try using another tool to save the values. this may have been a coolterm problem and not an Arduino problem. thank you

It is a coolterm problem. I'm not familiar with it but please check if you can find a setting for the line ending and play with that.

I have moved your topic to a more suitable location on the forum.

You're right. Serial.println() always sends CR and LF characters (0x13 0x10) as end of line, so Coolterm seems to be badly configured, stripping those away.
I don't use CoolTerm but I suppose OP sholud check what type of terminal emulation he's using, for this purpose the best choice is a "raw" one (e.g. pure ASCII, without any control characters).
Nothing to do with Arduino, anyway.

No offense intended, but you need to learn the tools that you use. I've installed coolterm now, encountered the same problem with some code that was in my Nano and had a look at the options.

Select the File Capture at the left and tick the Retain termination string.

After that, the file contains the <CR> and <LF>.

non taken and thank you. it did the job

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.