void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available ()){
Serial.print ((char) Serial.read ());
Serial.print ("\n");
}
}
i'm trrying to make a simple program that will print whatever i input to the Serial Monitor, i want that each time i press enter, Serial Monitor print whatever words i type into to a single line, than make a new line, but i can't seem to make it work, without the Serial.print ("\n");, it would just continue showing character i input in a single, but with it, it gives a new line to every character, for example i input "test", it send me
t
e
s
t
what i would like to want is it "to only make a new line per words i everytime i press enter", not every character i typed, must be something wrong in my code
I don't think the serial monitor sends what you have typed until you click the SEND button.
It will then send what you have typed along with any line ending characters you have selected in the drop down at the bottom of the serial monitor window.
you have this in the while loop, for each character your read
so no wonder you have a new line per character.
depending on how you configured your Serial monitor, CR, LF or both can be sent when you press enter on your keyboard. Those characters will thus arrive as well into your arduino
i think you missed the point i was trying to say, now it will continue every words i sent in a single line, so if i typed "test" send, then "Hello" send, the "Hello" will appear on the same line as "test", like:
What line ending setting do you have - see bottom of serial monitor window. I recall the options are something like: None, Line Feed, Carriage Return or CR+LF.
Hi everybody....i'm new to the forum and new to programming in Arduino IDE, i would like to make a simple program in Arduino Uno, which will print whatever we type in Serial Monitor (Integer or character) on to the window in Serial Monitor directly. I'm connecting my Arduino Uno to my PC through USB Cable, i'm new and just want to tweak arround the Arduino IDE
however when i tried to type a number or character, it just gives me a number of arround 50, this is my code :
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available ())
Serial.print (Serial.read ());
}
For example, if i input the number "1", Serial Monitor gives me a value of 49, then the number "2", with a reply of "50"...and so forth
What i want is when i type "1", Serial monitor gives me an answer of "1", when i type "a", gives me an "a"
i've match the Serial Monitor to the same bitrate, btw
following "casts" the value as a "char" forcing the print to print it as an ASCII char
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
if (Serial.available ())
Serial.print ((char) Serial.read ());
}
Your two topics on the same or similar subject have been merged.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.