I know this must seem a dumb question but I don't know.
Well, break it down, what are the two?
"\r\n" is two characters, "" is none.
So obviously they are not the same.
are they treated the same by the server is what I am asking.
What server? I'm supposed to just know?
you have to end with crlf, or two of them as someone said, an html protocol thing.
I guess, your answer is, "sending HTML", then. What does the HTML spec say?
println() prints whatever string is passed to it, and then . Any question about that, can be understood from that basic fact. Everything else you're talking about has nothing to do with print functions.
I do remember vaguely something about an HTTP request needing to be terminated with a double return, if that's what you mean.
client.println("\r\n");
is the same as
client.println();
client.println();
or
client.print("\r\n\r\n");
By the way, normally I don't point things out in this way, but really with 292 posts on the forum one would expect you to ask a question in the way that is outlined in the forum guidelines... in a number of ways, it isn't.
if by that you mean I should have exhausted all other possible sources of answers before coming here, I did. trust me.
now that you mention it, is client.println(); the same as client.println(""); or client.println('');
No, I mean you didn't provide enough background or contextual information.
client.println(); is the same as client.println("");
but
client.println('');
is not legal syntax, " by itself is not a valid expression.
client.println(''); two single quotes gets flagged but client.println(""); does not.
sevenoutpinball:
client.println(''); two single quotes gets flagged but client.println(""); does not.
...because that is a character literal and there is no character literal representation for a "nothing". It is a format that produces a char value. This format must always use some ASCII representation, and unlike a C string, it has a fixed size of 1.
so what does "" compile to? just crlf? Apparently. But how would anyone know?
You don't have to use the serial monitor of the Arduino IDE. You can use any serial terminal program, and many will show the hexadecimal values.
Using this test-sketch, I uploaded it. Then I opened the serial port of a serial terminal program, and then I pressed the reset button on the Arduino.
// Exploring the bytes sent.
// The AA, BB, CC hexadecimal values are markers.
void setup()
{
Serial.begin( 9600);
Serial.print( '\xAA');
Serial.println(""); // two double quotes
Serial.print( '\xBB');
Serial.println(); // no parameter
Serial.print( '\xCC');
Serial.print( "\r\n"); // carriage return + line feed
Serial.print( '\xDD');
// Serial.print( ''); // two single quotes causes compiler error
Serial.print( '\xEE');
Serial.print( "\x0D\x0A"); // Specifying with hexadecimal values
Serial.print( '\xFF');
}
void loop()
{
}
You can see the hexadecimal values between the marker bytes.
How would something else read it? Use tx and rx? Interesting idea thanks
sevenoutpinball:
so what does "" compile to? just crlf? Apparently. But how would anyone know?
Absolutely not. "" compiles to a C string that contains only one character, a "null terminator" that happens to have the value 0. Thus it is an "empty string".
The difference between print() and println() is that println() outputs after whatever was printed.
You specify what to print.
If you call print() that is all gets sent out.
If you call println() it sends what you asked, then outputs
Just that simple.
--- bill
that's what my question was, thank you.
sevenoutpinball:
that's what my question was, thank you.
Technically you asked if client.println("\r\n") was the same as client.println(""); ?
The answer to that is no.
print("") will print nothing.
So
println("\r\n") outputs and println("") outputs
--- bill
Oh, ok, I guess that's what I mean't to ask. And HTML requires you to end with two so println("\r\n") should satisfy the requirement.
Hi Koepel ... I have attached a schematic and like you say not checked output of 4069 and it is only 3ma typical so will have to have a look at that ...
Quick check on Hex Invertor Buffers looks like the CD4049 will handle LEDs ... its only 10ma per LED I need.
Also added sketch its only basic and after looking through documentation I did I may have enough without D0 and D1 and like someone suggested use a resistor ladder which would be easy for me ... I am using PCF8574 boards in this circuit as well they have 16 inputs and 16 outputs the sketch is on Github MERG-DEV ... the other way is using 74HC595 and 74HC165 which on there own I could probably use a sketch that Mike did on Dronebot Workshop but to integrate with this sketch is a bit above my knowledge ..
//sketch to set bi-colour LEds on Mimic Panel
//Version 1
//Edited 2nd Oct 2020
int pb1 = 2;//Declaring Pushbuttons
int pb2 = 3;
int pb3 = 4;
int pb4 = 5;
int pb6 = A0;
int pb7 = A1;
int pb8 = A2;
int PLed6A = 7;//Declaring LED positions
int PLed6B = 8;
int PLed7 = 9;
int PLed8 = 10;
int PLed9A = 11;
int PLed9B = 12;
int PLed1 = A3;
int PLed2 = A4;
int PLed3 = A5;
int PLed4 = 13;
int Buttonval1 = 0;
int Buttonval2 = 0;
int Buttonval3 = 0;
int Buttonval4 = 0;
int Buttonval6 = 0;
int Buttonval7 = 0;
int Buttonval8 = 0;
void setup() {
// Mimic Panel Setup
Serial.begin(9600);
Serial.println ( "Mimic Panel LED setting" );
pinMode(pb1,INPUT_PULLUP);//Pushbutton Inputs
pinMode(pb2,INPUT_PULLUP);
pinMode(pb3,INPUT_PULLUP);
pinMode(pb4,INPUT_PULLUP);
pinMode(pb6,INPUT_PULLUP);
pinMode(pb7,INPUT_PULLUP);
pinMode(pb8,INPUT_PULLUP);
pinMode(PLed6A,OUTPUT);//Bi-Colour LEDs outputs
pinMode(PLed6B,OUTPUT);
pinMode(PLed7,OUTPUT);
pinMode(PLed8,OUTPUT);
pinMode(PLed9A,OUTPUT);
pinMode(PLed9B,OUTPUT);
pinMode(PLed1,OUTPUT);
pinMode(PLed2,OUTPUT);
pinMode(PLed3,OUTPUT);
pinMode(PLed4,OUTPUT);
}
void loop() {
// Mimic IF statements set up
//LED States are HIGH is GREEN and Open
//LED States are LOW is RED and Closed
Buttonval1 = digitalRead(pb1);
Buttonval2 = digitalRead(pb2);
Buttonval3 = digitalRead(pb3);
Buttonval4 = digitalRead(pb4);
Buttonval6 = digitalRead(pb6);
Buttonval7 = digitalRead(pb7);
Buttonval8 = digitalRead(pb8);
if (Buttonval1 == LOW) {
digitalWrite(PLed6A, HIGH); // PLed6A is GREEN and Line 2 is Open
digitalWrite(PLed6B, LOW); // PLed6B is RED and Line is Closed
digitalWrite(PLed7, HIGH); // PLed7 is GREEN and Line 3 is Open
digitalWrite(PLed8, HIGH); // Pled8 is GREEN and Line 3 is Open
digitalWrite(PLed9A, LOW); // Pled9A is RED and Line is Closed
digitalWrite(PLed9B, HIGH); // PLed9B is Green and Line is Open
}
if (Buttonval2 == LOW) {
digitalWrite(PLed6A, LOW); // PLed6A is RED and Line 2 is Closed
digitalWrite(PLed6B, HIGH); // PLed6B is GREEN and Line is Open
digitalWrite(PLed7, LOW); // PLed7 is RED and Line 3 is Closed
digitalWrite(PLed8, LOW); // Pled8 is RED and Line 3 is Closed
digitalWrite(PLed9A, HIGH); // Pled9A is GREEN and Line is Open
digitalWrite(PLed9B, LOW); // PLed9B is RED and Line is Closed
}
if (Buttonval3 == LOW) {
digitalWrite(PLed6A, LOW); // PLed6A is RED and Line 2 is Closed
digitalWrite(PLed6B, HIGH); // PLed6B is GREEN and Line is Open
digitalWrite(PLed7, LOW); // PLed7 is RED and Line 3 is Closed
digitalWrite(PLed8, HIGH); // Pled8 is GREEN and Line 3 is Open
digitalWrite(PLed9A, LOW); // Pled9A is RED and Line is Closed
digitalWrite(PLed9B, HIGH); // PLed9B is GREEN and Line is Open
}
if (Buttonval4 == LOW) {
digitalWrite(PLed1, HIGH); // PLed1 is Green and Darcy Line is Open
digitalWrite(PLed2, LOW); // PLed2 is RED and Line 2 is Closed
digitalWrite(PLed3, LOW); // PLed3 is RED and Line is Closed
digitalWrite(PLed4, LOW); // Pled4 is RED and Line 3 is Closed
}
if (Buttonval6 == LOW) {
digitalWrite(PLed1, LOW); // PLed1 is RED and Darcy Line is Closed
digitalWrite(PLed2,HIGH); // PLed2 is GREEN and Line 2 is Open
digitalWrite(PLed3, LOW); // PLed3 is RED and Line is Closed
digitalWrite(PLed4, HIGH); // Pled8 is GREEN and Line 3 is Open
}
if (Buttonval7 == LOW) {
digitalWrite(PLed1, LOW); // PLed1 is RED and Darcy Line is Closed
digitalWrite(PLed2, LOW); // PLed2 is RED and Line is Closed
digitalWrite(PLed3, HIGH); // PLed3 is Green and Line Cross Line is Open
digitalWrite(PLed4, LOW); // Pled4 is RED and Line 3 is Closed
}
if (Buttonval8 == LOW) {
digitalWrite(PLed1, LOW); // PLed1 is RED and Darcy Line is Closed
digitalWrite(PLed2, HIGH); // PLed2 is RED and Line 2 is OPEN
digitalWrite(PLed3, LOW); // PLed3 is Red and Line Cross Line is Closed
digitalWrite(PLed4, HIGH); // Pled4 is Green and Line 3 is Open
}
}
For me, I would like to have full control over every led and control everything in software.
Why are there mosfets for the servo module ?
I'm not a fan of a resistor ladder for buttons. With bad contacts, an other button might be detected. When multiple buttons are pressed, there could be a problem as well. I had a consumer device once that did others things when pressing a button after years of usage. Well, that was no fun at all
The PCF8574 and the shift registers are common solutions. With short wires or soldered on a shield they cause no troubles.