In the SoftwareSerial reference page, find() doesn't figure in the list:
I can't understand what the terms "stream" or "serial buffer" mean. How does find() "read" data. This data that's coming from the stream/serial buffer, where does it come from? How and why is it produced?
The syntax says:
How do I know which "target" to give to the find() function? When would I decide to use the find() function?
I don't know why the target is "OK", I don't know what does it mean for the find("OK") to return a true? where does it find the target? and why is this a condition in the first place? I don't understand why SoftwareSerial.find() is used in the first place.
The following will wait until the user has typed the string hi in the serial console.
Serial.println("Please say something.");
while (not Serial.find("hi"));
Serial.println("Found \"hi\".");
If the user types hello (followed by an enter), nothing will happen. If something like oh hi there (followed by an enter) is typed, the program will respond and end.
No. Stream inherits from Print. SoftwareSerial inherits from Stream.
'Serial' is the name of an object of a class. Which class it is depends on which Arduino board you're using. On an Uno, Serial is an object of the HardwareSerial class - which inherits from Stream. On a Teensy 3.2, Serial is an object of the usb_serial_class class - which also inherits from Stream.
@jfjlaros
So the find function reads the string that's been entered in the serial monitor, is that it?
Also, in your example, I don't understand why there's a while loop instead of an if condition; I mean, we want to print "Found hi" if the serial monitor receives the string "hi", aren't we?
2. Assume that the following Newline terminated string is entered in the InputBox of the Serial Monitor.
I am OK 23
3. The characters of the string of Step-2 arrive at the UNO one-by-one and gets saved in the FIFO type Buffer of Fig-1 on interrupt basis and in the background.
4. The user wants that the data (23) of interest is after the substring OK of the arrived message. The find("OK") method helps to detect the OK substring and then returns true. The following sketch demonstrates the use of the Serial.find("OK") method.
If I say that '\0' refers to a non-printable character and its ASCII code is 0000000b (0x00 in hex base and 0 in decimal), can you tell the name of this character from the following Table (Fig-1)?
That is just about the worst ASCII table that I have ever seen. All the information is there but it is very confusing to read unless you know your way around ASCII and if you do then you probably don't need the table
How do you say that -- it's a NUL character? The Table of post #12 shows eight 0s (00000000); whereas, the NUL character has seven 0s (0000000 = 7-bit ASCII code) in the Table of post #9. So, which one is a correct Table?
They both are! The 8-bit table shows the first half of the ASCII table. The "characters" from 128-255 are what I think was called the extended character set. That includes additional foreign language letters, mathematical symbols, commercial/trade symbols and the box drawing symbols used in many MS-DOS based text "window" menu systems.