Echo
byte bytesIn;
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
bytesIn = Serial.read();
Serial.write(bytesIn);
}
}
LOOP
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello World");
}
how can i combine these two efficiently i tried to combine them but the outcome i want is different the outcome that i get from combining this two is whenever i input something like Help Me ( which is 7 characters included space ) that the times it will loop only but the result that they want is a unlimited loop
Tinkercad site code*
the attachment is the loop code in simulation how can i make the thing that i input be like that a unlimited loop
First off words without punctuation are hard to understand when there are so many of them. I think you mean to say
How can i combine these two efficiently? I tried to combine them, but the outcome I want is different the outcome that I get, from combining this two, is whenever I input something like, Help Me, ( which is 7 characters included space ) that the times it will loop only but the result that they want is a unlimited loop
Now the bit I don’t understand is
that the times it will loop only but the result that they want is a unlimited loop
So can you try again and explain what you want to happen?
Also can you post the code of your attempt to combine them.
byte bytesIn;
void setup() {
Serial.begin(9600);
}
void loop() {
if (Serial.available()) {
bytesIn = Serial.read();
Serial.write(bytesIn);
Serial.println("Serial.write");
}
}
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello World");
}
This two code i want to combine it and the suppose output should be anything I type should be in a loop
Still not quite getting it, I don’t think you have through it through. Do you want to print out constantly everything you have ever typed in? Or do you want to stop or change some time?
Like every time you press return it wipes out what has been outputted before and starts outputting just what you type after that?
If so you should just collect what you type into a variable of type string ( note this is not type String ) and print out that variable between the last two } } in the first code.
Please read the how to use this forum sticky post as it tells you how to post code correctly on this forum.
If you start writing programs by typing each command into a texteditor like the Arduino-IDE or if you want to combine code that was created or copied from somewhere else you need a basic understanding of what
void setup()
and
void loop()
does. Without this basic understanding it is likely that you get errors over and over again
which you can easily avoid through having this basic understanding.
To gain this basic understanding I recommend reading this tutorial:
setup and loop program-structure-flow
best regards Stefan