Code explanation needed please

QBasic and such "evolved" Basics, inherited the terminology from the original Basics, which had only GOSUB and RETURN. Most processors only have a JSR (jump to subroutine) and RTS (return from subroutine) or equivalent. Parameter and return values, if provided, have to be explicitly managed on the stack by both the caller and the callee.

I would like to know when it comes to naming variables what would the best practice be.
Could I use any length of name or is it best to keep it short as possible.

int Acc =10

vs

int Accessory_control_input = 10

Does long names have any memory impact.

No. The compiled code does not use the names

One line answers raise more questions than it is helpful.

How does the compiler distinguish between them. They surely can not be handled the same.

There is a memory impact for long names for the compiler itself. At least theoretically. Since the compiler will typically be running on some kind of PC with gigabytes of memory, it's sort-of irrelevant.
Part of the compiler's job is to take all those references to variable names, and convert them to references to memory locations in the code that actually runs on the microprocessor.
If your source code looks like:

     byte a = 123;
     byte anotherByteWithaLongName = 456;

the actual avr code will end up looking something like:

    ldi r16, 123
    sts 0x201, r16
    ldi r16, 456
    sts 0x202, r16

(where 0x201 is the memory address assigned to "a" and 0x202 is assigned to that other variable.)

Thank you for your explanation. It all makes sense now.

Could someone help to explain what meaning of "!" is. I come across it often but I not sure how to interpret it.

I found this in "Arduino Reference":
x != y (x is not equal to y)
There is no problem there and it is clear to understand. But then I see code like this and then i am lost:


    digitalWrite(ledPin, !digitalRead(ledPin));

another example:

fb = esp_camera_fb_get();
    if (!fb) {
      Serial.println("Camera capture failed");
      res = ESP_FAIL;

The first says, read ledPin, then write the opposite of that read back to the pin. The effect is to toggle the pin. If it reads low, it writes "not low", ie high. Next time, it reads high, and writes "not high" ie low.

In the second, that get function will return a true or false to the variable fb. Then the if says "if not fb", do stuff. The "if not fb" actually means "if fb is false"....

Thank you for your explanation, I do appreciate it a lot.

It was good to check with Arduino Reference - Arduino Reference first. In fact it contained the answer to your question about !, but the answer was in the Boolean Operators section, which has the "stand alone" ! whereas you were looking in the Comparison Operators section, which has the !=

Thanks I found it. I should have looked better.